scsi: pm: fix null pointer access during sg_open
When user space application opens any scsi generic device node (/dev/sg*),
we will have following call stack:
-> sg_open()
-> scsi_autopm_get_device()
-> pm_runtime_get_sync()
-> scsi_runtime_resume()
-> sdev_runtime_resume()
-> blk_post_runtime_resume()
The request queue device pointer (q->dev) is deferenced but it is NULL.
q->dev is assigned when blk_pm_runtime_init() is called which only takes
place for sd/sr type scsi devices.
SCSI generic driver handles runtime PM get/put on its instead of block
layer handling it. We can move the runtime PM get/put responsibility to
block layer only if all the requests handled by sg driver are getting
inserted to block layer request queue but this is not always true.
For example, if LLD ioctl is issued via scsi generic ioctl then it may
not get converted to block layer request (and hence doesn't get inserted
into block layer request queue) and this may put us in situation where
LLD driver handler the ioctl when it's runtime suspended.
Better solution would be to let the sg driver manage its own runtime PM
get/sync operations and fix the broken scsi_runtime_suspend and
scsi_runtime_resume callbacks to handle SCSI devices which do not have
upper layer driver (like SCSI disk).
Change-Id: I1cae7f992f21a1c420d38c275a817d06baa8923d
Signed-off-by:
Gilad Broner <gbroner@codeaurora.org>
[subhashj@codeaurora.org: fixed the compilation failure]
Signed-off-by:
Subhash Jadavani <subhashj@codeaurora.org>
[venkatg@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by:
Venkat Gopalakrishnan <venkatg@codeaurora.org>
Loading
Please register or sign in to comment