Skip to content

Commit 060b85b

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "This is three essential bug fixes for various SCSI parts. The only affected users are SCSI multi-path via device handler (basically all the enterprise) and mvsas users. The dh bugs are an async entanglement in boot resulting in a serious WARN_ON trip and a use after free on remove leading to a crash with strict memory accounting. The mvsas bug manifests as a null deref oops but only on abort sequences; however, these can commonly occur with SATA attached devices, hence the fix" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi_dh: don't try to load a device handler during async probing scsi_dh: fix use-after-free when removing scsi device mvsas: Fix NULL pointer dereference in mvs_slot_task_free
2 parents af7eba0 + d6a32b9 commit 060b85b

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

drivers/scsi/mvsas/mv_sas.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,8 @@ static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
887887
static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
888888
struct mvs_slot_info *slot, u32 slot_idx)
889889
{
890+
if (!slot)
891+
return;
890892
if (!slot->task)
891893
return;
892894
if (!sas_protocol_ata(task->task_proto))

drivers/scsi/scsi_dh.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,20 @@ int scsi_dh_add_device(struct scsi_device *sdev)
226226

227227
drv = scsi_dh_find_driver(sdev);
228228
if (drv)
229-
devinfo = scsi_dh_lookup(drv);
229+
devinfo = __scsi_dh_lookup(drv);
230230
if (devinfo)
231231
err = scsi_dh_handler_attach(sdev, devinfo);
232232
return err;
233233
}
234234

235-
void scsi_dh_remove_device(struct scsi_device *sdev)
235+
void scsi_dh_release_device(struct scsi_device *sdev)
236236
{
237237
if (sdev->handler)
238238
scsi_dh_handler_detach(sdev);
239+
}
240+
241+
void scsi_dh_remove_device(struct scsi_device *sdev)
242+
{
239243
device_remove_file(&sdev->sdev_gendev, &scsi_dh_state_attr);
240244
}
241245

drivers/scsi/scsi_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ extern struct async_domain scsi_sd_probe_domain;
173173
/* scsi_dh.c */
174174
#ifdef CONFIG_SCSI_DH
175175
int scsi_dh_add_device(struct scsi_device *sdev);
176+
void scsi_dh_release_device(struct scsi_device *sdev);
176177
void scsi_dh_remove_device(struct scsi_device *sdev);
177178
#else
178179
static inline int scsi_dh_add_device(struct scsi_device *sdev) { return 0; }
180+
static inline void scsi_dh_release_device(struct scsi_device *sdev) { }
179181
static inline void scsi_dh_remove_device(struct scsi_device *sdev) { }
180182
#endif
181183

drivers/scsi/scsi_sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
399399

400400
sdev = container_of(work, struct scsi_device, ew.work);
401401

402+
scsi_dh_release_device(sdev);
403+
402404
parent = sdev->sdev_gendev.parent;
403405

404406
spin_lock_irqsave(sdev->host->host_lock, flags);

0 commit comments

Comments
 (0)