* [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one()
@ 2022-11-22 1:57 Yuan Can
2022-11-23 8:14 ` Ming Lei
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yuan Can @ 2022-11-22 1:57 UTC (permalink / raw)
To: don.brace, jejb, martin.petersen, ming.lei, storagedev,
linux-scsi; +Cc: yuancan
The hpda_alloc_ctlr_info() allocates h and its field reply_map, however in
hpsa_init_one(), if alloc_percpu() failed, the hpsa_init_one() jumps to
clean1 directly, which frees h and leaks the h->reply_map.
Fix by calling hpda_free_ctlr_info() to release h->replay_map and h
instead free h directly.
Fixes: 8b834bff1b73 ("scsi: hpsa: fix selection of reply queue")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
drivers/scsi/hpsa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index f8e832b1bc46..e5cbc97a5ea4 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8925,7 +8925,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
destroy_workqueue(h->monitor_ctlr_wq);
h->monitor_ctlr_wq = NULL;
}
- kfree(h);
+ hpda_free_ctlr_info(h);
return rc;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one()
2022-11-22 1:57 [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one() Yuan Can
@ 2022-11-23 8:14 ` Ming Lei
2022-11-24 3:45 ` Martin K. Petersen
2022-12-01 3:45 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2022-11-23 8:14 UTC (permalink / raw)
To: Yuan Can; +Cc: don.brace, jejb, martin.petersen, storagedev, linux-scsi
On Tue, Nov 22, 2022 at 01:57:51AM +0000, Yuan Can wrote:
> The hpda_alloc_ctlr_info() allocates h and its field reply_map, however in
> hpsa_init_one(), if alloc_percpu() failed, the hpsa_init_one() jumps to
> clean1 directly, which frees h and leaks the h->reply_map.
> Fix by calling hpda_free_ctlr_info() to release h->replay_map and h
> instead free h directly.
>
> Fixes: 8b834bff1b73 ("scsi: hpsa: fix selection of reply queue")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
> drivers/scsi/hpsa.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index f8e832b1bc46..e5cbc97a5ea4 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -8925,7 +8925,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> destroy_workqueue(h->monitor_ctlr_wq);
> h->monitor_ctlr_wq = NULL;
> }
> - kfree(h);
> + hpda_free_ctlr_info(h);
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Thanks,
Ming
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one()
2022-11-22 1:57 [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one() Yuan Can
2022-11-23 8:14 ` Ming Lei
@ 2022-11-24 3:45 ` Martin K. Petersen
2022-12-01 3:45 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2022-11-24 3:45 UTC (permalink / raw)
To: Yuan Can; +Cc: don.brace, jejb, martin.petersen, ming.lei, storagedev,
linux-scsi
Yuan,
> The hpda_alloc_ctlr_info() allocates h and its field reply_map,
> however in hpsa_init_one(), if alloc_percpu() failed, the
> hpsa_init_one() jumps to clean1 directly, which frees h and leaks the
> h->reply_map. Fix by calling hpda_free_ctlr_info() to release
> h->replay_map and h instead free h directly.
Applied to 6.2/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one()
2022-11-22 1:57 [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one() Yuan Can
2022-11-23 8:14 ` Ming Lei
2022-11-24 3:45 ` Martin K. Petersen
@ 2022-12-01 3:45 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2022-12-01 3:45 UTC (permalink / raw)
To: jejb, Yuan Can, linux-scsi, storagedev, ming.lei, don.brace
Cc: Martin K . Petersen
On Tue, 22 Nov 2022 01:57:51 +0000, Yuan Can wrote:
> The hpda_alloc_ctlr_info() allocates h and its field reply_map, however in
> hpsa_init_one(), if alloc_percpu() failed, the hpsa_init_one() jumps to
> clean1 directly, which frees h and leaks the h->reply_map.
> Fix by calling hpda_free_ctlr_info() to release h->replay_map and h
> instead free h directly.
>
>
> [...]
Applied to 6.2/scsi-queue, thanks!
[1/1] scsi: hpsa: Fix possible memory leak in hpsa_init_one()
https://git.kernel.org/mkp/scsi/c/9c9ff300e0de
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-01 3:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-22 1:57 [PATCH] scsi: hpsa: Fix possible memory leak in hpsa_init_one() Yuan Can
2022-11-23 8:14 ` Ming Lei
2022-11-24 3:45 ` Martin K. Petersen
2022-12-01 3:45 ` 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