From patchwork Sun Jan 15 11:24:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 43835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp699416wrn; Sun, 15 Jan 2023 03:39:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtuAUPwhXFMIyGwEPF7AetC3tIEPHdlXEm2aGV9FNeQ8/jyhuNeTcBvDB5vAmTV2tt8QN2Q X-Received: by 2002:a17:902:e152:b0:193:3de:b777 with SMTP id d18-20020a170902e15200b0019303deb777mr32133283pla.43.1673782749574; Sun, 15 Jan 2023 03:39:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673782749; cv=none; d=google.com; s=arc-20160816; b=J2oD7qA4wwN1bNl1VDonT38pjWyW/3b0cdDeAGJ99bW2HRcdG4sdtscgW1RYTnKQky OAfmhyYZoo82HyT+8tnlVyi1hzzqAuEpQR2tFddEp4dTYYuisdP1J9cSx3KcDagFsxm8 gjhZFTV3n6Ql3N/6btI7P4In50WzE0ACEeSaFGXHwl3GSC3fzZks4Cow5qR7UatcaRbb nQnKP4ioC32A5/62bMumg6E5AVyPV7rfHBuE06xs49baSmRU0z2Q+MFpNA3pc110Qr+f 1QYmYc0V13zlQfdF9IgozvVHAizSsK+xgoPwDGS+ZS3lYg062ESjv4MtPq2kBe6qirzG cNQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=TKlVqnk6ATVXosq0NaY/Bakhx19PORkfYR+ztwt+UuI=; b=zYK6CGArzBzxcXFjbAWJK18oGvUSD4isLzEklCmyr0Xy4K3DqfsQSFKKquE4Q/H/e1 27PYRGSvioJXdhnoEmCC7ebjMiNKFphD7AU4zfYXrM+Ng0EjAooBeRG/u6WDvWpz8yNu vhY6zXtPKX3imyHfThaGSw837JrVIz2WIjl8oCRNgmj5pq2+MpVf4XYO9M83rTzmYHcb 5zrzLxBwwi0mQy2QU5Nk6Xn02EsSe3i+S25bRvI94iW3xNPAMFDqW+d3QlvIuUTAsl/Q KzF2IsOiZz3ZBYziwIoxbWjkdEFw5s7rdjScWTfTIKq/s4tDoPRRc3B5cc88PzSriwcv e/Wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a170902e89200b001926a062cefsi28637527plg.43.2023.01.15.03.38.56; Sun, 15 Jan 2023 03:39:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbjAOLYb (ORCPT + 99 others); Sun, 15 Jan 2023 06:24:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbjAOLY0 (ORCPT ); Sun, 15 Jan 2023 06:24:26 -0500 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012CC1732 for ; Sun, 15 Jan 2023 03:24:24 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id H17bpDGm8IopLH17bpa0Ms; Sun, 15 Jan 2023 12:24:23 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 15 Jan 2023 12:24:23 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Arthur Simchaev , Bean Huo Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-scsi@vger.kernel.org Subject: [PATCH] scsi: ufs: core: Fix an error handling path in ufshcd_read_desc_param() Date: Sun, 15 Jan 2023 12:24:17 +0100 Message-Id: <2c6e42205e5ec22e5e8c7c85c6deb8fde31c74da.1673781835.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755088420085478532?= X-GMAIL-MSGID: =?utf-8?q?1755088420085478532?= If an error occurs, some memory may need to be freed, as in the other error handling paths. Before the commit in the Fixes tag, this test was done before the memory allocation, so there was no issue. Fixes: 16ed9d312b42 ("scsi: ufs: core: Remove ufshcd_map_desc_id_to_length()") Signed-off-by: Christophe JAILLET --- drivers/ufs/core/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 6ec65dcdd689..097f2489bc91 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -3452,7 +3452,8 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, if (param_offset >= buff_len) { dev_err(hba->dev, "%s: Invalid offset 0x%x in descriptor IDN 0x%x, length 0x%x\n", __func__, param_offset, desc_id, buff_len); - return -EINVAL; + ret = -EINVAL; + goto out; } /* Sanity check */