lkml.org 
[lkml]   [2019]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.14 12/25] scsi: qla2xxx: Fix possible fcport null-pointer dereferences
    Date
    From: Jia-Ju Bai <baijiaju1990@gmail.com>

    [ Upstream commit e82f04ec6ba91065fd33a6201ffd7cab840e1475 ]

    In qla2x00_alloc_fcport(), fcport is assigned to NULL in the error
    handling code on line 4880:
    fcport = NULL;

    Then fcport is used on lines 4883-4886:
    INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
    INIT_WORK(&fcport->reg_work, qla_register_fcport_fn);
    INIT_LIST_HEAD(&fcport->gnl_entry);
    INIT_LIST_HEAD(&fcport->list);

    Thus, possible null-pointer dereferences may occur.

    To fix these bugs, qla2x00_alloc_fcport() directly returns NULL
    in the error handling code.

    These bugs are found by a static analysis tool STCheck written by us.

    Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
    Acked-by: Himanshu Madhani <hmadhani@marvell.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/scsi/qla2xxx/qla_init.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
    index aef1e1a555350..0e154fea693e7 100644
    --- a/drivers/scsi/qla2xxx/qla_init.c
    +++ b/drivers/scsi/qla2xxx/qla_init.c
    @@ -4252,7 +4252,7 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
    ql_log(ql_log_warn, vha, 0xd049,
    "Failed to allocate ct_sns request.\n");
    kfree(fcport);
    - fcport = NULL;
    + return NULL;
    }
    INIT_WORK(&fcport->del_work, qla24xx_delete_sess_fn);
    INIT_LIST_HEAD(&fcport->gnl_entry);
    --
    2.20.1
    \
     
     \ /
      Last update: 2019-08-06 23:55    [W:3.470 / U:0.684 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site