public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Bart Van Assche <bvanassche@acm.org>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Steffen Maier <maier@linux.ibm.com>
Subject: Re: [PATCH] scsi: simplify registration of scsi host sysfs attributes
Date: Tue, 16 Nov 2021 12:29:09 +0900	[thread overview]
Message-ID: <00694cf2-b6d6-fd40-2d80-a36d306302b9@opensource.wdc.com> (raw)
In-Reply-To: <52cea40c-1de2-9742-168a-c8ff0a29f0bf@acm.org>

On 2021/11/16 11:18, Bart Van Assche wrote:
> On 11/15/21 1:29 AM, Damien Le Moal wrote:
>> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
>> index 8049b00b6766..c3b6812aac5b 100644
>> --- a/drivers/scsi/hosts.c
>> +++ b/drivers/scsi/hosts.c
>> @@ -359,6 +359,7 @@ static void scsi_host_dev_release(struct device *dev)
>>   static struct device_type scsi_host_type = {
>>   	.name =		"scsi_host",
>>   	.release =	scsi_host_dev_release,
>> +	.groups =	scsi_sysfs_shost_attr_groups,
>>   };
> 
> Many SCSI LLDs use class_to_shost() to convert a device pointer into a SCSI host
> pointer. This patch makes the use of that macro very confusing since the SCSI
> host class is no longer involved in attribute registration.

OK. But at least I think we should fix this:

WARN_ON_ONCE(j >= ARRAY_SIZE(shost->shost_dev_attr_groups));

to change it into:

if (WARN_ON_ONCE(j >= ARRAY_SIZE(shost->shost_dev_attr_groups)))
	shost->shost_dev_attr_groups[j] = NULL;

to guarantee that the attribute groups array is NULL terminated, as it should
be. This will ensure that we do not end up with a kernel crash when a buggy
driver is loaded. No ?

> 
> Thanks,
> 
> Bart.
> 


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2021-11-16  3:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15  9:29 [PATCH] scsi: simplify registration of scsi host sysfs attributes Damien Le Moal
2021-11-15 11:43 ` Steffen Maier
2021-11-15 17:36 ` Bart Van Assche
2021-11-16  3:29   ` Damien Le Moal [this message]
2021-11-16  4:22     ` Bart Van Assche
2021-11-16  4:54       ` Damien Le Moal
2021-11-19  8:24 ` [scsi] c8f22155c6: BUG:KASAN:slab-out-of-bounds_in_show_shost_state kernel test robot

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=00694cf2-b6d6-fd40-2d80-a36d306302b9@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=bvanassche@acm.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maier@linux.ibm.com \
    --cc=martin.petersen@oracle.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