@@ -3129,8 +3129,7 @@ fc_remote_port_create(struct Scsi_Host *shost, int channel,
list_del(&rport->peers);
scsi_host_put(shost); /* for fc_host->rport list */
spin_unlock_irqrestore(shost->host_lock, flags);
- put_device(dev->parent);
- kfree(rport);
+ put_device(dev);
return NULL;
}
@@ -3930,8 +3929,7 @@ fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
scsi_host_put(shost); /* for fc_host->vport list */
fc_host->npiv_vports_inuse--;
spin_unlock_irqrestore(shost->host_lock, flags);
- put_device(dev->parent);
- kfree(vport);
+ put_device(dev);
return error;
}
Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, it need be freed if device_add(dev) returns error, as comment of device_add() says, it should call put_device() to drop the reference on error. Fix it by calling put_device(dev) so that the name can be freed in kobject_cleanup(). In fc_rport_dev_release() and fc_vport_dev_release(), it will put refcount of dev->parent and free the port, so the release code of them in error path can be removed. Fixes: 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array") Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/scsi/scsi_transport_fc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)