Skip to content

Commit

Permalink
firewire: fw-sbp2: fix NULL pointer deref. in scsi_remove_device
Browse files Browse the repository at this point in the history
Fix a kernel bug when unplugging an SBP-2 device after having its
scsi_device already removed via the "delete" sysfs attribute.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Stefan Richter committed Feb 19, 2008
1 parent 5513c5f commit 33f1c6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/firewire/fw-sbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,10 @@ static void sbp2_release_target(struct kref *kref)
sbp2_unblock(tgt);

list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
if (lu->sdev)
if (lu->sdev) {
scsi_remove_device(lu->sdev);

scsi_device_put(lu->sdev);
}
sbp2_send_management_orb(lu, tgt->node_id, lu->generation,
SBP2_LOGOUT_REQUEST, lu->login_id, NULL);

Expand Down Expand Up @@ -886,12 +887,11 @@ static void sbp2_login(struct work_struct *work)
if (IS_ERR(sdev))
goto out_logout_login;

scsi_device_put(sdev);

/* Unreported error during __scsi_add_device() */
smp_rmb(); /* get current card generation */
if (generation != device->card->generation) {
scsi_remove_device(sdev);
scsi_device_put(sdev);
goto out_logout_login;
}

Expand Down

0 comments on commit 33f1c6c

Please sign in to comment.