bnx2fc: do not scan uninitialized lists in case of error.
authorMaurizio Lombardi <mlombard@redhat.com>
Thu, 19 Jun 2014 13:05:00 +0000 (15:05 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 25 Jun 2014 11:29:30 +0000 (13:29 +0200)
In case of of error, the bnx2fc_cmd_mgr_alloc() function will call
the bnx2fc_cmd_mgr_free() to perform the cleanup.
The problem is that in one case the latter may try to scan
some not-yet initialized lists, resulting in a kernel panic.

This patch prevents this from happening by freeing the lists
before calling bnx2fc_cmd_mgr_free().

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Acked-by: Eddie Wai <eddie.wai@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/bnx2fc/bnx2fc_io.c

index 32a5e0a2a66934a1413e6da4537d1a93c08ff0e1..7bc47fc7c686afe9d4b88e520475b39e8eeba2a8 100644 (file)
@@ -282,6 +282,8 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
                                       arr_sz, GFP_KERNEL);
        if (!cmgr->free_list_lock) {
                printk(KERN_ERR PFX "failed to alloc free_list_lock\n");
+               kfree(cmgr->free_list);
+               cmgr->free_list = NULL;
                goto mem_err;
        }