From: John Garry <john.g.garry@oracle.com>
To: Eshaan Deshmukh <eshaan2031@icloud.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Jason Yan <yanaijie@huawei.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] scsi: libsas: Handle errors in sas_ex_discover_expander()
Date: Wed, 12 Aug 2026 14:33:43 +0100 [thread overview]
Message-ID: <bbc02974-b661-423c-ae5b-9743791d1769@oracle.com> (raw)
In-Reply-To: <20260811162223.411052-4-eshaan2031@icloud.com>
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:
prev parent reply other threads:[~2026-08-12 13:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 16:22 [PATCH v2 0/3] scsi: libsas: Handle errors in 3 functions Eshaan Deshmukh
2026-08-11 16:22 ` [PATCH v2 1/3] scsi: libsas: Handle errors in sas_ex_add_parent_port() Eshaan Deshmukh
2026-08-11 16:22 ` [PATCH v2 2/3] scsi: libsas: Handle errors in sas_set_ex_phy() Eshaan Deshmukh
2026-08-12 13:28 ` John Garry
2026-08-11 16:22 ` [PATCH v2 3/3] scsi: libsas: Handle errors in sas_ex_discover_expander() Eshaan Deshmukh
2026-08-12 13:33 ` John Garry [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bbc02974-b661-423c-ae5b-9743791d1769@oracle.com \
--to=john.g.garry@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=eshaan2031@icloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=yanaijie@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®