@@ -1262,12 +1262,17 @@ 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)
+ return -ENOMEM;
+
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) {
+ pr_err("fcoe: Failed to attach to the FC transport\n");
+ fc_release_transport(fcoe_nport_scsi_transport);
+ fcoe_nport_scsi_transport = NULL;
+ return -ENOMEM;
}
return 0;
If it fails to alloc fcoe_vport_scsi_transport in fcoe_if_init, we should check the err and free allocted fcoe_nport_scsi_transport. Also return ENOMEM instead of ENODEV. Fixes: 8ca86f84dd5f ("[SCSI] fcoe: prepare fcoe for using fcoe transport") Signed-off-by: YueHaibing <yuehaibing@huawei.com> --- drivers/scsi/fcoe/fcoe.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)