lkml.org 
[lkml]   [2023]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH-next v2 2/2] scsi: fix iscsi rescan fails to create block device
From
Date
Hi, Greg

在 2023/01/28 18:45, Greg KH 写道:
>> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
>> index cac7c902cf70..a22109cdb8ef 100644
>> --- a/drivers/scsi/scsi_sysfs.c
>> +++ b/drivers/scsi/scsi_sysfs.c
>> @@ -1535,9 +1535,7 @@ static void __scsi_remove_target(struct scsi_target *starget)
>> if (sdev->channel != starget->channel ||
>> sdev->id != starget->id)
>> continue;
>> - if (sdev->sdev_state == SDEV_DEL ||
>> - sdev->sdev_state == SDEV_CANCEL ||
>> - !get_device(&sdev->sdev_gendev))
>> + if (!get_device_unless_zero(&sdev->sdev_gendev))
>
> If sdev_gendev is 0 here, the object is gone and you are working with
> memory that is already freed so something is _VERY_ wrong.

In fact, this patch will work:

In __scsi_remove_target(), 'host_lock' is held to protect iterating
siblings, and object will wait for this lock in
scsi_device_dev_release() to remove siblings. Hence sdev will not be
freed untill the lock is released.

Thanks,
Kuai
>
> This isn't ok, sorry.
>
> greg k-h
> .
>

\
 
 \ /
  Last update: 2023-03-27 00:00    [W:2.258 / U:0.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site