mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
scsi: bnx2fc: Fix error handling in probe()
[ Upstream commitb2d3492fc5] 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:853e2bd210("[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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8d27f830b6
commit
59411d98fb
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user