* [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2
@ 2020-12-25 8:35 Dinghao Liu
2021-01-13 1:19 ` Karan Tilak Kumar (kartilak)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dinghao Liu @ 2020-12-25 8:35 UTC (permalink / raw)
To: dinghao.liu, kjlu
Cc: Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel
When ioread32() returns 0xFFFFFFFF, we should execute
cleanup functions like other error handling paths before
returning.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/scsi/fnic/vnic_dev.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index a2beee6e09f0..5988c300cc82 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -444,7 +444,8 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index);
if (fetch_index == 0xFFFFFFFF) { /* check for hardware gone */
pr_err("error in devcmd2 init");
- return -ENODEV;
+ err = -ENODEV;
+ goto err_free_wq;
}
/*
@@ -460,7 +461,7 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring,
DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE);
if (err)
- goto err_free_wq;
+ goto err_disable_wq;
vdev->devcmd2->result =
(struct devcmd2_result *) vdev->devcmd2->results_ring.descs;
@@ -481,8 +482,9 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
err_free_desc_ring:
vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring);
-err_free_wq:
+err_disable_wq:
vnic_wq_disable(&vdev->devcmd2->wq);
+err_free_wq:
vnic_wq_free(&vdev->devcmd2->wq);
err_free_devcmd2:
kfree(vdev->devcmd2);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2
2020-12-25 8:35 [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2 Dinghao Liu
@ 2021-01-13 1:19 ` Karan Tilak Kumar (kartilak)
2021-01-13 5:33 ` Martin K. Petersen
2021-01-13 5:48 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Karan Tilak Kumar (kartilak) @ 2021-01-13 1:19 UTC (permalink / raw)
To: Dinghao Liu, kjlu
Cc: Satish Kharat (satishkh), Sesidhar Baddela (sebaddel),
James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel
Acked-by: Karan Tilak Kumar <kartilak@cisco.com>
Regards,
Karan
-----Original Message-----
From: Dinghao Liu <dinghao.liu@zju.edu.cn>
Sent: Friday, December 25, 2020 12:35 AM
To: dinghao.liu@zju.edu.cn; kjlu@umn.edu
Cc: Satish Kharat (satishkh) <satishkh@cisco.com>; Sesidhar Baddela (sebaddel) <sebaddel@cisco.com>; Karan Tilak Kumar (kartilak) <kartilak@cisco.com>; James E.J. Bottomley <jejb@linux.ibm.com>; Martin K. Petersen <martin.petersen@oracle.com>; linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2
When ioread32() returns 0xFFFFFFFF, we should execute cleanup functions like other error handling paths before returning.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/scsi/fnic/vnic_dev.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c index a2beee6e09f0..5988c300cc82 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -444,7 +444,8 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index);
if (fetch_index == 0xFFFFFFFF) { /* check for hardware gone */
pr_err("error in devcmd2 init");
- return -ENODEV;
+ err = -ENODEV;
+ goto err_free_wq;
}
/*
@@ -460,7 +461,7 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring,
DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE);
if (err)
- goto err_free_wq;
+ goto err_disable_wq;
vdev->devcmd2->result =
(struct devcmd2_result *) vdev->devcmd2->results_ring.descs;
@@ -481,8 +482,9 @@ static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
err_free_desc_ring:
vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring);
-err_free_wq:
+err_disable_wq:
vnic_wq_disable(&vdev->devcmd2->wq);
+err_free_wq:
vnic_wq_free(&vdev->devcmd2->wq);
err_free_devcmd2:
kfree(vdev->devcmd2);
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2
2020-12-25 8:35 [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2 Dinghao Liu
2021-01-13 1:19 ` Karan Tilak Kumar (kartilak)
@ 2021-01-13 5:33 ` Martin K. Petersen
2021-01-13 5:48 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-01-13 5:33 UTC (permalink / raw)
To: Dinghao Liu
Cc: kjlu, Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel
Dinghao,
> When ioread32() returns 0xFFFFFFFF, we should execute
> cleanup functions like other error handling paths before
> returning.
Applied to 5.12/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2
2020-12-25 8:35 [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2 Dinghao Liu
2021-01-13 1:19 ` Karan Tilak Kumar (kartilak)
2021-01-13 5:33 ` Martin K. Petersen
@ 2021-01-13 5:48 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-01-13 5:48 UTC (permalink / raw)
To: Dinghao Liu, kjlu
Cc: Martin K . Petersen, Karan Tilak Kumar, James E.J. Bottomley,
Satish Kharat, linux-kernel, Sesidhar Baddela, linux-scsi
On Fri, 25 Dec 2020 16:35:20 +0800, Dinghao Liu wrote:
> When ioread32() returns 0xFFFFFFFF, we should execute
> cleanup functions like other error handling paths before
> returning.
Applied to 5.11/scsi-fixes, thanks!
[1/1] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2
https://git.kernel.org/mkp/scsi/c/d6e3ae76728c
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-13 5:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-25 8:35 [PATCH] scsi: fnic: Fix memleak in vnic_dev_init_devcmd2 Dinghao Liu
2021-01-13 1:19 ` Karan Tilak Kumar (kartilak)
2021-01-13 5:33 ` Martin K. Petersen
2021-01-13 5:48 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).