From patchwork Wed Sep 28 15:38:27 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: 9355825 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 DE0EC600C8 for ; Thu, 29 Sep 2016 07:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0F2229894 for ; Thu, 29 Sep 2016 07:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4CE12989B; Thu, 29 Sep 2016 07:56:41 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 530CA29894 for ; Thu, 29 Sep 2016 07:56:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u8T7sHiO002769; Thu, 29 Sep 2016 03:54:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u8SFcX29023701 for ; Wed, 28 Sep 2016 11:38:33 -0400 Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8SFcX03027270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 28 Sep 2016 11:38:33 -0400 Received: from mout.web.de (mout.web.de [212.227.17.11]) (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 E494C283F2F; Wed, 28 Sep 2016 15:38:31 +0000 (UTC) Received: from [192.168.1.2] ([78.48.47.99]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LaTeV-1b5Bfv3fo7-00mHGp; Wed, 28 Sep 2016 17:38:29 +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: <2cc0fee8-2228-1f0c-9428-3b872a39e64b@users.sourceforge.net> Date: Wed, 28 Sep 2016 17:38:27 +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:OmJ0xObARSIGaFhHZJWKJBrH34V55t6qYeoHl9Cw7OCuPZn6iHM UcinvCI7x9DcE80pYlkEvuB9cVzQGZTM96Vr1HN7sSehrulOZPquUsFgX0nsQTUrgso52TY 3IUYnyw/W264JSD2MTYdByl97lMnLer5+mEdB3GxdXBWQFtcFNfTNKRGqHY6cLe22pYoGkE 50/551//BHuwp1RkQ4K3Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:fQ8n5sHuGZQ=:pXI36rahOoMq8cAKilfRld YXr1aliQG1LkTwRm3DG3goAUkWvN2Jb2w0zrwydO+OgUPgicg2/7KQ3BFh8E1a5DfEBI8FFhg MVjAvfx9ahspMqkD/bbExg2whmmJSsnHP7YOiVr1uEBhUeEQw3qfHQupLAAZji38G2uV3GS/Y 12N4ullcho+5tZcnGYPFsDP2GYQ8ADTP2gajoZn7pMxBqhqrupWFeNbmmFJXbnSagJS3obONs cwdIjgXQD9+Klq4hjjuuFMC/V0D/pi4qNJ47y2AdqIa6w/5W9bqNtgNkZLbXJ1XO7mr4+09MR ATm5Gay5M84G3av2DY9c+JZGlSAUGEwlVCUxdNPO0DUU3cY0CefokM+EsJiER/W46clLjFjPn Otk93TW3PAKpQQtNQ3HrwbV7mMl9/u1V+NU2s1xjHLHMM6cRTpgUWxQdlCpAtAshU/J3OhboH IEbBl4Ygr9+xZWOLI8UNDw5khYZtzaLNVsR3IQUa3Zpz36tzB5qsGsKfIb05imylDlSqg64Kl 9vxRJroAn8DG6I5H8ioTtfWKT68+csvuzyPjgwq4Og+M9YSq/ZO8FDCPYch/khrDVzDCnUQ6g skZCkFrumJDUfAflEwZX5Y3/M/gyDbfDZ5r/zZnvyPoJ/JT7+IyOlzKRDvzd9ujFMx2SdUH0F DDXsjKPx0Tjezmtxc2zJyI98QHYL04TDNmAYSN3TmiqG4UfjOb2ed99K3LeFRmD4xYtM7g74c XkskTCvmE1pl/QcHULiBL3IfXwZaCzuBKTthTSU05JEcXL/xnE9kOsiz9Vy24iFPWwjH8JFbl XKIXDhy X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 28 Sep 2016 15:38:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 28 Sep 2016 15:38:32 +0000 (UTC) for IP:'212.227.17.11' 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) 212.227.17.11 mout.web.de 212.227.17.11 mout.web.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 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 02/10] md/dm-crypt: Reduce the scope for a variable in crypt_alloc_tfms() 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 14:05:25 +0200 Move the definition for the variable "err" (including its declaration) into an if branch (so that the corresponding setting will only be performed if a call of the function "crypto_alloc_skcipher" failed as before this refactoring). Signed-off-by: Markus Elfring --- drivers/md/dm-crypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 68971a2..88a3b62 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1452,7 +1452,6 @@ static void crypt_free_tfms(struct crypt_config *cc) static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode) { unsigned i; - int err; cc->tfms = kcalloc(cc->tfms_count, sizeof(*cc->tfms), GFP_KERNEL); if (!cc->tfms) @@ -1461,7 +1460,8 @@ static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode) for (i = 0; i < cc->tfms_count; i++) { cc->tfms[i] = crypto_alloc_skcipher(ciphermode, 0, 0); if (IS_ERR(cc->tfms[i])) { - err = PTR_ERR(cc->tfms[i]); + int err = PTR_ERR(cc->tfms[i]); + crypt_free_tfms(cc); return err; }