[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b71bca20-401f-c877-168c-c26ca1c282d1@sangfor.com.cn>
Date: Wed, 5 Apr 2023 12:27:32 +0800
From: Ding Hui <dinghui@...gfor.com.cn>
To: jejb@...ux.ibm.com, Jiri Kosina <jikos@...nel.org>,
"Martin K. Petersen" <martin.petersen@...cle.com>
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
Michal Kolar <mich.k@...nam.cz>
Subject: Re: [PATCH] scsi: ses: Handle enclosure with just a primary component
gracefully
On 2023/4/5 4:26, James Bottomley wrote:
> On Tue, 2023-04-04 at 21:23 +0200, Jiri Kosina wrote:
>> From: Jiri Kosina <jkosina@...e.cz>
>>
>> This reverts 3fe97ff3d9493 ("scsi: ses: Don't attach if enclosure has
>> no components") and introduces proper handling of case where there
>> are no detected secondary components, but primary component
>> (enumerated in num_enclosures) does exist. That fix was originally
>> proposed by Ding Hui <dinghui@...gfor.com.cn>.
>
> I think everything in here looks fine except this:
>
>> --- a/drivers/scsi/ses.c
>> +++ b/drivers/scsi/ses.c
>> @@ -509,9 +509,6 @@ static int ses_enclosure_find_by_addr(struct
>> enclosure_device *edev,
>> int i;
>> struct ses_component *scomp;
>>
>> - if (!edev->component[0].scratch)
>> - return 0;
>> -
>> for (i = 0; i < edev->components; i++) {
>> scomp = edev->component[i].scratch;
>> if (scomp->addr != efd->addr)
>
> If you remove the check, then scomp could be NULL here and we'll oops
> on scomp->addr.
I think we should remove the check, because the edev->components
represented the effectiveness of array pointers, so we need check
edev->components firstly instead of checking edev->component[0].scratch,
if edev->components is 0, we won't enter the for loop, don't worry about
dereference scomp.
>
> Regards,
>
> James
>
>
--
Thanks,
-dinghui
Powered by blists - more mailing lists