diff mbox series

scsi: megaraid_sas: fix double kfree

Message ID 1659424729-46502-1-git-send-email-kanie@linux.alibaba.com (mailing list archive)
State Accepted
Headers show
Series scsi: megaraid_sas: fix double kfree | expand

Commit Message

Guixin Liu Aug. 2, 2022, 7:18 a.m. UTC
When alloc log_to_span fail, call kfree(instance->ctrl_context) first,
then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call
kfree(instance->ctrl_context) second.

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Guixin Liu Aug. 8, 2022, 2:37 a.m. UTC | #1
Hi,

Gentle ping.

在 2022/8/2 15:18, Guixin Liu 写道:
> When alloc log_to_span fail, call kfree(instance->ctrl_context) first,
> then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call
> kfree(instance->ctrl_context) second.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
>   drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index 5b5885d..3e9b2b0 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -5311,7 +5311,6 @@ void megasas_fusion_ocr_wq(struct work_struct *work)
>   		if (!fusion->log_to_span) {
>   			dev_err(&instance->pdev->dev, "Failed from %s %d\n",
>   				__func__, __LINE__);
> -			kfree(instance->ctrl_context);
>   			return -ENOMEM;
>   		}
>   	}
Sumit Saxena Aug. 9, 2022, 7:37 a.m. UTC | #2
On Tue, Aug 2, 2022 at 12:49 PM Guixin Liu <kanie@linux.alibaba.com> wrote:
>
> When alloc log_to_span fail, call kfree(instance->ctrl_context) first,
> then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call
> kfree(instance->ctrl_context) second.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Looks good.
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Martin K. Petersen Aug. 12, 2022, 2:13 a.m. UTC | #3
Guixin,

> When alloc log_to_span fail, call kfree(instance->ctrl_context) first,
> then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call
> kfree(instance->ctrl_context) second.

Applied to 5.20/scsi-staging, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 5b5885d..3e9b2b0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -5311,7 +5311,6 @@  void megasas_fusion_ocr_wq(struct work_struct *work)
 		if (!fusion->log_to_span) {
 			dev_err(&instance->pdev->dev, "Failed from %s %d\n",
 				__func__, __LINE__);
-			kfree(instance->ctrl_context);
 			return -ENOMEM;
 		}
 	}