Re: [PATCH v2 3/3] scsi: libsas: Handle errors in sas_ex_discover_expander()
John Garry <[email protected]> Wed, 12 Aug 2026 14:33:43 +0100
| Newsgroups | gmane.linux.kernel,gmane.linux.scsi |
|---|---|
| Organization | Oracle Corporation |
| Message-ID | <[email protected]> |
On 11/08/2026 17:22, Eshaan Deshmukh wrote:
> phy->port = sas_port_alloc(&parent->rphy->dev, phy_id);
> - /* FIXME: better error handling */
> - BUG_ON(sas_port_add(phy->port) != 0);
> + if (!phy->port) {
> + sas_put_device(child);
> + return NULL;
> + }
>
> + res = sas_port_add(phy->port);
> + if (res) {
We never pay attention to the specific value of res, so it's not
required, i.e. we can have:
if (sas_port_add(phy->port)) {
You can also change the sas_discover_expander() call (not shown) for this.
> + sas_port_free(phy->port);
> + phy->port = NULL;
> + sas_put_device(child);
> + return NULL;
> + }
There is code later after the sas_discover_expander() call which does
the same tidy-up and more, so maybe it's better to have tidy-up labels,
like:
if (!phy->port)
goto out_put_device;
...
res = sas_port_add(phy->port);
if (res)
goto out_free_port;
You get the idea...
>
> switch (phy->attached_dev_type) {
> case SAS_EDGE_EXPANDER_DEVICE: