diff mbox series

[v4,23/31] scsi: pm8001: fix memory leak in pm8001_chip_fw_flash_update_req()

Message ID 20220217132956.484818-24-damien.lemoal@opensource.wdc.com (mailing list archive)
State Superseded
Headers show
Series libsas and pm8001 fixes | expand

Commit Message

Damien Le Moal Feb. 17, 2022, 1:29 p.m. UTC
In pm8001_chip_fw_flash_update_build(), if
pm8001_chip_fw_flash_update_build() fails, the struct fw_control_ex
allocated must be freed.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jinpu Wang Feb. 17, 2022, 7:42 p.m. UTC | #1
On Thu, Feb 17, 2022 at 2:30 PM Damien Le Moal
<damien.lemoal@opensource.wdc.com> wrote:
>
> In pm8001_chip_fw_flash_update_build(), if
> pm8001_chip_fw_flash_update_build() fails, the struct fw_control_ex
> allocated must be freed.
>
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>

> ---
>  drivers/scsi/pm8001/pm8001_hwi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
> index 431fc9160637..41077c84eec9 100644
> --- a/drivers/scsi/pm8001/pm8001_hwi.c
> +++ b/drivers/scsi/pm8001/pm8001_hwi.c
> @@ -4873,8 +4873,10 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
>         ccb->ccb_tag = tag;
>         rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info,
>                 tag);
> -       if (rc)
> +       if (rc) {
> +               kfree(fw_control_context);
>                 pm8001_tag_free(pm8001_ha, tag);
> +       }
>
>         return rc;
>  }
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 431fc9160637..41077c84eec9 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -4873,8 +4873,10 @@  pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
 	ccb->ccb_tag = tag;
 	rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info,
 		tag);
-	if (rc)
+	if (rc) {
+		kfree(fw_control_context);
 		pm8001_tag_free(pm8001_ha, tag);
+	}
 
 	return rc;
 }