From patchwork Tue Sep 6 15:45:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Bogdanov X-Patchwork-Id: 603288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F59CECAAA1 for ; Tue, 6 Sep 2022 16:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238979AbiIFQRv (ORCPT ); Tue, 6 Sep 2022 12:17:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238860AbiIFQRS (ORCPT ); Tue, 6 Sep 2022 12:17:18 -0400 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C827198A; Tue, 6 Sep 2022 08:45:44 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 5F02F448D0; Tue, 6 Sep 2022 15:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1662479141; x=1664293542; bh=M7bIgwjGB8IpWO1nTeQabcybK tqluBRod/zJ/cf+cGs=; b=cRj26RzCwu2esdCIycTlUeDbnmJ2Y+WV4BIIq/y6n sj+5IEFQPr4xA4gr4XdwMdoUEGAIZVbdipU+4BnGtc60ITSmLgWO3Iq531ov4sFP hgpCy/Tak0+2x/FHLOxr3pkHyJWY7/k0lbrUB6yMULX7vnb5ZfHFvqYxaUuvF2Uv cQ= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ezlcOz7VnU-5; Tue, 6 Sep 2022 18:45:41 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id CF25043BF7; Tue, 6 Sep 2022 18:45:41 +0300 (MSK) Received: from T-EXCH-08.corp.yadro.com (172.17.11.58) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Tue, 6 Sep 2022 18:45:41 +0300 Received: from NB-591.corp.yadro.com (10.199.18.20) by T-EXCH-08.corp.yadro.com (172.17.11.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Tue, 6 Sep 2022 18:45:40 +0300 From: Dmitry Bogdanov To: Martin Petersen , CC: Mike Christie , , , Roman Bolshakov , Dmitry Bogdanov Subject: [PATCH 1/7] scsi: target: core: Add cleanup sequence in core_tpg_register() Date: Tue, 6 Sep 2022 18:45:13 +0300 Message-ID: <20220906154519.27487-2-d.bogdanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906154519.27487-1-d.bogdanov@yadro.com> References: <20220906154519.27487-1-d.bogdanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.199.18.20] X-ClientProxiedBy: T-EXCH-02.corp.yadro.com (172.17.10.102) To T-EXCH-08.corp.yadro.com (172.17.11.58) Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Roman Bolshakov It does not change any functionality but allows to introduce more steps in the cleanup sequence without code duplication later. Signed-off-by: Roman Bolshakov Signed-off-by: Dmitry Bogdanov --- drivers/target/target_core_tpg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 736847c933e5..f0d38d77edcc 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -484,10 +484,8 @@ int core_tpg_register( ret = core_tpg_add_lun(se_tpg, se_tpg->tpg_virt_lun0, true, g_lun0_dev); - if (ret < 0) { - kfree(se_tpg->tpg_virt_lun0); - return ret; - } + if (ret < 0) + goto out_free_lun0; } pr_debug("TARGET_CORE[%s]: Allocated portal_group for endpoint: %s, " @@ -497,6 +495,10 @@ int core_tpg_register( se_tpg->proto_id, se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg)); return 0; + +out_free_lun0: + kfree(se_tpg->tpg_virt_lun0); + return ret; } EXPORT_SYMBOL(core_tpg_register);