res = sas_notify_lldd_dev_found(dev);
if (res)
- return res;
+ goto out_err2;
switch (dev->dev_type) {
case SATA_DEV:
default:
break;
}
+ if (res)
+ goto out_err;
sas_notify_lldd_dev_gone(dev);
- if (!res) {
- sas_notify_lldd_dev_found(dev);
- }
+ res = sas_notify_lldd_dev_found(dev);
+ if (res)
+ goto out_err2;
+
+ res = sas_rphy_add(dev->rphy);
+ if (res)
+ goto out_err;
+
+ return res;
+
+out_err:
+ sas_notify_lldd_dev_gone(dev);
+out_err2:
+ sas_rphy_free(dev->rphy);
+ dev->rphy = NULL;
return res;
}
res = sas_notify_lldd_dev_found(dev);
if (res)
- return res;
+ goto out_err2;
res = sas_rphy_add(dev->rphy);
if (res)
/* do this to get the end device port attributes which will have
* been scanned in sas_rphy_add */
sas_notify_lldd_dev_gone(dev);
- sas_notify_lldd_dev_found(dev);
+ res = sas_notify_lldd_dev_found(dev);
+ if (res)
+ goto out_err3;
return 0;
out_err:
sas_notify_lldd_dev_gone(dev);
+out_err2:
+ sas_rphy_free(dev->rphy);
+ dev->rphy = NULL;
+ return res;
+out_err3:
+ sas_rphy_delete(dev->rphy);
+ dev->rphy = NULL;
return res;
}
}
if (error) {
+ spin_lock(&port->dev_list_lock);
+ list_del_init(&port->port_dev->dev_list_node);
+ spin_unlock(&port->dev_list_lock);
+
kfree(port->port_dev); /* not kobject_register-ed yet */
port->port_dev = NULL;
}