From: John Garry <john.g.garry@oracle.com>
To: Yang Yingliang <yangyingliang@huawei.com>,
jejb@linux.ibm.com, linux-scsi@vger.kernel.org,
Greg KH <gregkh@linuxfoundation.org>
Cc: martin.petersen@oracle.com
Subject: Re: [PATCH v2] scsi: scsi_transport_sas: fix error handling in sas_rphy_add()
Date: Fri, 18 Nov 2022 09:18:40 +0000 [thread overview]
Message-ID: <9ff2a73c-bd45-c19e-3624-8816c5bac9ab@oracle.com> (raw)
In-Reply-To: <45fb08d9-ebda-4c8e-23cc-49f79e5ffde8@huawei.com>
On 18/11/2022 03:11, Yang Yingliang wrote:
>>>> );
>> There is a slight problem with doing this in that if
>> transport_device_add() ever fails it's likely because memory pressure
>> caused the allocation of the internal_container to fail. What that
>> means is that the visible sysfs attributes don't get added, but
>> otherwise the rphy is fully functional as far as the driver sees it, so
>> this condition doesn't have to be a fatal error which kills the device.
>>
>> There are two ways of handling this:
>>
>> 1. The above to move the condition from an ignored to a fatal error.
>> It's so rare that we almost never see it in practice and if it
>> ever happened, the machine is so low on memory that something
>> else is bound to fail an allocation and kill the device anyway,
>> so treating it as non-fatal likely serves no purpose.
>> 2. Simply to make the assumption that transport_remove_device() is
>> idempotent true by adding a flag in the internal_class to signify
>> removal is required. This would preserve current behaviour and
>> have the bonus that it only requires a single patch, not one
>> patch per transport class object that has this problem.
>>
>> I'd probably prefer 2. since it's way less work, but others might have
>> different opinions.
> Current some callers ignore the return value of transport_add_device(),
> if it fails,
> it will cause null-ptr-deref in transport_remove_device().
>
> James suggested that add some check in transport_remove_device(), so all
> can
> be fix in one patch.
>
> Do you have any suggestion for this ?
Personally I prefer 1. However did you develop a prototype patch for how
2. would look? And how many changes are still required for 1.?
Thanks,
John
next prev parent reply other threads:[~2022-11-18 9:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 14:44 [PATCH v2] scsi: scsi_transport_sas: fix error handling in sas_rphy_add() Yang Yingliang
2022-11-11 15:51 ` James Bottomley
2022-11-18 3:11 ` Yang Yingliang
2022-11-18 9:18 ` John Garry [this message]
2022-11-19 8:58 ` Yang Yingliang
2022-11-21 12:51 ` John Garry
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=9ff2a73c-bd45-c19e-3624-8816c5bac9ab@oracle.com \
--to=john.g.garry@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=yangyingliang@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