diff options
author | zhengbin <zhengbin13@huawei.com> | 2019-08-20 07:43:09 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2019-09-11 03:19:55 +0200 |
commit | f96d279f0a5e53f4b96b16a5c08e2c75e139ba0b (patch) | |
tree | 281609ded73bf63bec5b7fba8ee49ceb4b7a3460 /drivers/scsi/fcoe/fcoe.c | |
parent | scsi: ufs-hisi: use devm_platform_ioremap_resource() to simplify code (diff) | |
download | linux-f96d279f0a5e53f4b96b16a5c08e2c75e139ba0b.tar.xz linux-f96d279f0a5e53f4b96b16a5c08e2c75e139ba0b.zip |
scsi: fcoe: fix null-ptr-deref Read in fc_release_transport
In fcoe_if_init, if fc_attach_transport(&fcoe_vport_fc_functions)
fails, need to free the previously memory and return fail, otherwise
will trigger null-ptr-deref Read in fc_release_transport.
fcoe_exit
fcoe_if_exit
fc_release_transport(fcoe_vport_scsi_transport)
Link: https://lore.kernel.org/r/1566279789-58207-1-git-send-email-zhengbin13@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/fcoe/fcoe.c')
-rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 8e217ab7646e..813f26d8b417 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1250,15 +1250,21 @@ static int __init fcoe_if_init(void) /* attach to scsi transport */ fcoe_nport_scsi_transport = fc_attach_transport(&fcoe_nport_fc_functions); + if (!fcoe_nport_scsi_transport) + goto err; + fcoe_vport_scsi_transport = fc_attach_transport(&fcoe_vport_fc_functions); - - if (!fcoe_nport_scsi_transport) { - printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n"); - return -ENODEV; - } + if (!fcoe_vport_scsi_transport) + goto err_vport; return 0; + +err_vport: + fc_release_transport(fcoe_nport_scsi_transport); +err: + printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n"); + return -ENODEV; } /** |