Message ID | 20231123081941.24854-1-dinghao.liu@zju.edu.cn (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | scsi: be2iscsi: fix a memleak in beiscsi_init_wrb_handle | expand |
On 11/23/23 2:19 AM, Dinghao Liu wrote: > When an error occurs in the for loop of beiscsi_init_wrb_handle(), > we should free phwi_ctxt->be_wrbq before returning an error code > to prevent potential memleak. > > Fixes: a7909b396ba7 ("[SCSI] be2iscsi: Fix dynamic CID allocation Mechanism in driver") > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> > --- > drivers/scsi/be2iscsi/be_main.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c > index e48f14ad6dfd..06acb5ff609e 100644 > --- a/drivers/scsi/be2iscsi/be_main.c > +++ b/drivers/scsi/be2iscsi/be_main.c > @@ -2710,6 +2710,7 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) > kfree(pwrb_context->pwrb_handle_base); > kfree(pwrb_context->pwrb_handle_basestd); > } > + kfree(phwi_ctxt->be_wrbq); > return -ENOMEM; > } > Reviewed-by: Mike Christie <michael.christie@oracle.com>
On Thu, 23 Nov 2023 16:19:41 +0800, Dinghao Liu wrote: > When an error occurs in the for loop of beiscsi_init_wrb_handle(), > we should free phwi_ctxt->be_wrbq before returning an error code > to prevent potential memleak. > > Applied to 6.7/scsi-fixes, thanks! [1/1] scsi: be2iscsi: fix a memleak in beiscsi_init_wrb_handle https://git.kernel.org/mkp/scsi/c/235f2b548d7f
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index e48f14ad6dfd..06acb5ff609e 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -2710,6 +2710,7 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) kfree(pwrb_context->pwrb_handle_base); kfree(pwrb_context->pwrb_handle_basestd); } + kfree(phwi_ctxt->be_wrbq); return -ENOMEM; }
When an error occurs in the for loop of beiscsi_init_wrb_handle(), we should free phwi_ctxt->be_wrbq before returning an error code to prevent potential memleak. Fixes: a7909b396ba7 ("[SCSI] be2iscsi: Fix dynamic CID allocation Mechanism in driver") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> --- drivers/scsi/be2iscsi/be_main.c | 1 + 1 file changed, 1 insertion(+)