All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: bnx2fc: Fix error handling in probe()
@ 2019-01-24 10:29 Dan Carpenter
  2019-01-29  6:31 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-01-24 10:29 UTC (permalink / raw)
  To: kernel-janitors

There are two issues here.  First if cmgr->hba is not set early enough
then it leads to a NULL dereference.  Second if we don't completely
initialize cmgr->io_bdt_pool[] then we end up dereferencing
uninitialized pointers.

Fixes: 853e2bd2103a ("[SCSI] bnx2fc: Broadcom FCoE offload driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 350257c13a5b..bc9f2a2365f4 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -240,6 +240,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
 		return NULL;
 	}
 
+	cmgr->hba = hba;
 	cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list),
 				  GFP_KERNEL);
 	if (!cmgr->free_list) {
@@ -256,7 +257,6 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
 		goto mem_err;
 	}
 
-	cmgr->hba = hba;
 	cmgr->cmds = (struct bnx2fc_cmd **)(cmgr + 1);
 
 	for (i = 0; i < arr_sz; i++)  {
@@ -295,7 +295,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
 
 	/* Allocate pool of io_bdts - one for each bnx2fc_cmd */
 	mem_size = num_ios * sizeof(struct io_bdt *);
-	cmgr->io_bdt_pool = kmalloc(mem_size, GFP_KERNEL);
+	cmgr->io_bdt_pool = kzalloc(mem_size, GFP_KERNEL);
 	if (!cmgr->io_bdt_pool) {
 		printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n");
 		goto mem_err;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: bnx2fc: Fix error handling in probe()
  2019-01-24 10:29 [PATCH] scsi: bnx2fc: Fix error handling in probe() Dan Carpenter
@ 2019-01-29  6:31 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2019-01-29  6:31 UTC (permalink / raw)
  To: kernel-janitors


Dan,

> There are two issues here.  First if cmgr->hba is not set early enough
> then it leads to a NULL dereference.  Second if we don't completely
> initialize cmgr->io_bdt_pool[] then we end up dereferencing
> uninitialized pointers.

Applied to 5.0/scsi-fixes, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-29  6:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 10:29 [PATCH] scsi: bnx2fc: Fix error handling in probe() Dan Carpenter
2019-01-29  6:31 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.