Re: [PATCH 5.15 177/570] scsi: core: Fix error handling for scsi_alloc_sdev()

Harshit Mogalapalli
2026-04-17T08:36:57Z

Hi Junxiao,

>>> -    if (scsi_realloc_sdev_budget_map(sdev, depth)) {
>>> -        kref_put(&sdev->host->tagset_refcnt, scsi_mq_free_tags);
>>> -        put_device(&starget->dev);
>>> -        kfree(sdev);
>>> -        goto out;
>>> -    }
>>> +    if (scsi_realloc_sdev_budget_map(sdev, depth))
>>> +        goto out_device_destroy;
>>
>> I have run an AI assisted backport review and it spotted an issue: I
>> have taken a look and the issue is:
>>
>>
>> 5.15.y doesn't have commit: 21008cabc5d9 ("scsi: core: Move two
>> statements") - v6.19-rc1 based so backporting this patch introduces
>> something like:
>>
>>   if (scsi_realloc_sdev_budget_map(sdev, depth))
>>           goto out_device_destroy;
>>
>>   scsi_change_queue_depth(sdev, depth);
>>   scsi_sysfs_device_initialize(sdev);
>>
>>   ...
>>   out_device_destroy:
>>           __scsi_remove_device(sdev);
>>
>>
>> calling put_device() before  device_initialize(), so I think we should
>> drop this patch in stable branches which don't have commit:
>> 21008cabc5d9 ("scsi: core: Move two statements") in them. Upstream
>> moved scsi_sysfs_device_initialize() above the budget_map() call.
>>
>> Thoughts ?
>>
> Right, this commit should be backported as well. Otherwise we could see
> this warning.
>
> "kobject: '%s' (%p): is not initialized, yet kobject_put() is being
> called.\n"
>

Thanks for confirming, Sasha dropped it from the stable queue for this
release.

4th one in:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/commit/?id=f1885e089cd1533e346cb4845e5d6d101303dc44

Thanks,
Harshit

> Thanks,
>
> Junxiao.
>
>> I see the same problem in other stable branches as well.
>>
>> Thanks,
>> Harshit
>>
>>
>>>       scsi_change_queue_depth(sdev, depth);
>>>
>>>
>>>
>>