On Tue, Jan 24, 2023 at 03:30:25PM +0100, mwilck@xxxxxxxx wrote: > From: Martin Wilck <mwilck@xxxxxxxx> > > Since the might_sleep() annotation was added in scsi_device_put() and > alua_rtpg_queue(), we have seen repeated reports of "BUG: sleeping function > called from invalid context" [1], [2]. alua_rtpg_queue() is always called > from contexts where the caller must hold at least one reference to the scsi > device in question. This means that the reference taken by > alua_rtpg_queue() itself can't be the last one, and thus can be dropped > without entering the code path in which scsi_device_put() might actually > sleep. If there is always guaranteed to be another reference, why does this code even grab one? The pattern of dropping a reference that can't be the last is pretty nonsensical.