From nobody Mon Sep 15 04:16:02 2025 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 4BA1EC63797 for ; Sun, 15 Jan 2023 11:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231146AbjAOLYc (ORCPT ); Sun, 15 Jan 2023 06:24:32 -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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 >=3D buff_len) { dev_err(hba->dev, "%s: Invalid offset 0x%x in descriptor IDN 0x%x, lengt= h 0x%x\n", __func__, param_offset, desc_id, buff_len); - return -EINVAL; + ret =3D -EINVAL; + goto out; } =20 /* Sanity check */ --=20 2.34.1