scsi: target: Fix unmap setup during configuration
authorMike Christie <michael.christie@oracle.com>
Fri, 9 Feb 2024 21:52:47 +0000 (15:52 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Feb 2024 01:42:00 +0000 (20:42 -0500)
commit4cbec7e89a416294c46e71c967b57b9119fe0054
treec9e432550e65f3f98ed25c8cbb4036dd514f1866
parent17e94b2585417e04dabc2f13bc03b4665ae687f3
scsi: target: Fix unmap setup during configuration

This issue was found and also debugged by Carl Lei <me@xecycle.info>.

If the device is not enabled, iblock/file will have not setup their
se_device to bdev/file mappings. If a user tries to config the unmap
settings at this time, we will then crash trying to access a NULL pointer
where the bdev/file should be.

This patch adds a check to make sure the device is configured before
we try to call the configure_unmap callout.

Fixes: 34bd1dcacf0d ("scsi: target: Detect UNMAP support post configuration")
Reported-by: Carl Lei <me@xecycle.info>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240209215247.5213-1-michael.christie@oracle.com
Reviewed-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_configfs.c