Skip to content

Commit b2d3492

Browse files
Dan Carpentermartinkpetersen
authored andcommitted
scsi: bnx2fc: Fix error handling in probe()
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: 853e2bd ("[SCSI] bnx2fc: Broadcom FCoE offload driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 40d07b5 commit b2d3492

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/scsi/bnx2fc/bnx2fc_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
240240
return NULL;
241241
}
242242

243+
cmgr->hba = hba;
243244
cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list),
244245
GFP_KERNEL);
245246
if (!cmgr->free_list) {
@@ -256,7 +257,6 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
256257
goto mem_err;
257258
}
258259

259-
cmgr->hba = hba;
260260
cmgr->cmds = (struct bnx2fc_cmd **)(cmgr + 1);
261261

262262
for (i = 0; i < arr_sz; i++) {
@@ -295,7 +295,7 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
295295

296296
/* Allocate pool of io_bdts - one for each bnx2fc_cmd */
297297
mem_size = num_ios * sizeof(struct io_bdt *);
298-
cmgr->io_bdt_pool = kmalloc(mem_size, GFP_KERNEL);
298+
cmgr->io_bdt_pool = kzalloc(mem_size, GFP_KERNEL);
299299
if (!cmgr->io_bdt_pool) {
300300
printk(KERN_ERR PFX "failed to alloc io_bdt_pool\n");
301301
goto mem_err;

0 commit comments

Comments
 (0)