From patchwork Wed Sep 28 15:46:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9355827 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 023B9600C8 for ; Thu, 29 Sep 2016 07:56:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7A5F29894 for ; Thu, 29 Sep 2016 07:56:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBDE22989A; Thu, 29 Sep 2016 07:56:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8402129894 for ; Thu, 29 Sep 2016 07:56:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8T7sHYi040543; Thu, 29 Sep 2016 03:54:17 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u8SFk7th024418 for ; Wed, 28 Sep 2016 11:46:07 -0400 Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8SFk7Yl030065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 28 Sep 2016 11:46:07 -0400 Received: from mout.web.de (mout.web.de [217.72.192.78]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3761C624B6; Wed, 28 Sep 2016 15:46:06 +0000 (UTC) Received: from [192.168.1.2] ([78.48.47.99]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MOzoR-1btxka3Ve3-006PDx; Wed, 28 Sep 2016 17:46:04 +0200 To: dm-devel@redhat.com, linux-raid@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Shaohua Li References: <566ABCD9.1060404@users.sourceforge.net> <7c232017-e291-fd2d-5516-26e5150d90df@users.sourceforge.net> From: SF Markus Elfring Message-ID: <5d9795a8-a7ee-915c-ac83-f61100e9e639@users.sourceforge.net> Date: Wed, 28 Sep 2016 17:46:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <7c232017-e291-fd2d-5516-26e5150d90df@users.sourceforge.net> X-Provags-ID: V03:K0:gNnIaZAasGtB+e1hT6iV4z7LGeKaPct8GNy0mran+7BOKKtfSba fHIjeVVM0yws3PuWeG8vDiG5kGk0mhNhEamZ0C66cmUu5rjSaYAKz1mcUbW68ia75uviPXc Zu2sjGwsga5eL7+KwpcMW5fGZCDZX6jRypQbRZN1q7D1GZASEYWKI2PzGWdUOn7fxqgTlUD lRdzigUqs+OD8wNZ4HBJQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:aisv1x15LpE=:7boLQ7ILAhZAByBjvZrnro fwlRpWZ1+zHkyyFlQwUvgc46YiDweyrg4juOf6G+5ig0KYtZSgRmz0GDGHfbIMXBAHakcnCq0 Y39eGLBZxbiw2ogYPQHfJxLEEIhbpuwAL6F0V+d2G45DSw1l9Ay+NvHUPzZjcNSQqBXuMXVmx 5y7wPubRVZD/P6vGdD3eNO/iIQUF5JDwYqhkYshaK2sg3SOkISI65/aQDyh+1o+qo6uzCFs+G Sg22Mkadt76snQ782ody/0vNwCWBfPhDN2/uIlMgPDU7GQzEecaVQdhDBM1cfKi0GkED8pQhT SP4rOZ+bk8EjqkZtPXMypeaA4aY78ceoKvtbuasIPd0IHBbnnoKTzZjt2a5ix6RxQ/+EJme7U 3JSo9WzpAVKmInRFFhJOaQmZ+FWCIGTDtaaB0jUpim+hzUHpuS8/ckQBKIr++huattQJcNjVt MGb849mywL3tknRP0p2TW/h97nCYMtbu3GeocXzcj5DkWTOTy00JfvDG3Sv8qnbYg+rulg7IU xa7VxGT21Z1NqV3RE/I9Y8r4+g9ZzY0Vagl4cAa+R1h+YrVASdPXO7HeEjRydo8l6/G9C3+ye B8iUMvPDFgBdEyaELpYY7XRn333HfwUUh7aO7dQjqkQAEjG+YDdL4w5Lq/mXuh5KKyN8apR9X yBlGSRn44dD8dk7Hv6mhHNbuvwiOBhDgvzVdUcr0j3coAwx5WkwaBFfn57jSKQB/QDLVBG0UU 1A3qe3Xiu9nEuv4UVWse8nB9Lf4OPyAGKyX2uLkuaef+DnITWTpz0PzYchAm5FMyzgFij9d0y jobUbZ/ X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 28 Sep 2016 15:46:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 28 Sep 2016 15:46:06 +0000 (UTC) for IP:'217.72.192.78' DOMAIN:'mout.web.de' HELO:'mout.web.de' FROM:'elfring@users.sourceforge.net' RCPT:'' X-RedHat-Spam-Score: 0.079 (BAYES_50, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 217.72.192.78 mout.web.de 217.72.192.78 mout.web.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 29 Sep 2016 03:54:16 -0400 Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML Subject: [dm-devel] [PATCH 09/10] md/dm-crypt: Two checks and one function call less in crypt_iv_essiv_ctr() after error detection X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 28 Sep 2016 16:38:37 +0200 The kfree() function was called in one case by the crypt_iv_essiv_ctr() function during error handling even if the passed variable "salt" contained a null pointer. * Adjust a jump target according to the Linux coding style convention. * Delete this function call and a condition check which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/md/dm-crypt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 47f6265..53a9155 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -382,7 +382,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, if (!salt) { ti->error = "Error kmallocing salt storage in ESSIV"; err = -ENOMEM; - goto bad; + goto free_hash; } cc->iv_gen_private.essiv.salt = salt; @@ -397,11 +397,8 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, cc->iv_private = essiv_tfm; return 0; - -bad: - if (hash_tfm && !IS_ERR(hash_tfm)) - crypto_free_ahash(hash_tfm); - kfree(salt); +free_hash: + crypto_free_ahash(hash_tfm); return err; }