From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753149AbbBWSPV (ORCPT ); Mon, 23 Feb 2015 13:15:21 -0500 Received: from smtp.infotech.no ([82.134.31.41]:51825 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753103AbbBWSPT (ORCPT ); Mon, 23 Feb 2015 13:15:19 -0500 Message-ID: <54EB6E26.6090209@interlog.com> Date: Mon, 23 Feb 2015 13:15:02 -0500 From: Douglas Gilbert Reply-To: dgilbert@interlog.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: SF Markus Elfring , "James E. J. Bottomley" , linux-scsi@vger.kernel.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: Re: [PATCH 3/3] SCSI-debug: Fix exception handling for an alignment/granularity mismatch in scsi_debug_init() References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <54D4F7DF.8070008@users.sourceforge.net> <54D4F952.5070206@users.sourceforge.net> In-Reply-To: <54D4F952.5070206@users.sourceforge.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15-02-06 12:26 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Fri, 6 Feb 2015 17:57:32 +0100 > > The scsi_debug_init() function returned directly if the data items "alignment" > and "granularity" did not fit together. > > Let us improve the affected exception handling by replacing the return > statement by a goto statement so that previously allocated resources will also > be appropriately released. > > Signed-off-by: Markus Elfring Acked-by: Douglas Gilbert > --- > drivers/scsi/scsi_debug.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c > index 756b7be..2c78663 100644 > --- a/drivers/scsi/scsi_debug.c > +++ b/drivers/scsi/scsi_debug.c > @@ -4909,7 +4909,8 @@ static int __init scsi_debug_init(void) > scsi_debug_unmap_alignment) { > pr_err("%s: ERR: unmap_granularity <= unmap_alignment\n", > __func__); > - return -EINVAL; > + ret = -EINVAL; > + goto free_dif; > } > > map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; >