From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux1394-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: [PATCH] firewire: fw-sbp2: fix NULL pointer deref in scsi_remove_device
Date: Sun, 17 Feb 2008 19:17:04 +0100 (CET) [thread overview]
Message-ID: <tkrat.bc89a18c9ce7df0b@s5r6.in-berlin.de> (raw)
In-Reply-To: <tkrat.9103805c20697161@s5r6.in-berlin.de>
I wrote:
> There is unfortunately another bug. If the user manually removes the
> scsi_device by writing into its "delete" sysfs attribute, the following
> will happen when the SBP-2 device is plugged out:
>
> BUG: unable to handle kernel NULL pointer dereference at 00000000000000b8
> IP: [<ffffffff804188c6>] mutex_lock_nested+0x7b/0x270
...
> Call Trace:
> [<ffffffff8041a305>] ? _spin_unlock_irqrestore+0x49/0x68
> [<ffffffff8036a670>] ? scsi_remove_device+0x1e/0x33
> [<ffffffff880ef799>] ? :firewire_sbp2:sbp2_release_target+0x33/0xca
> [<ffffffff880ef766>] ? :firewire_sbp2:sbp2_release_target+0x0/0xca
> [<ffffffff802ec6df>] ? kref_put+0x41/0x4c
> [<ffffffff880ef117>] ? :firewire_sbp2:sbp2_remove+0x10/0x14
...
> ---[ end trace 2a9c61e9883e29d2 ]---
>
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>
---
drivers/firewire/fw-sbp2.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Index: linux-2.6.25-rc2/drivers/firewire/fw-sbp2.c
===================================================================
--- linux-2.6.25-rc2.orig/drivers/firewire/fw-sbp2.c
+++ linux-2.6.25-rc2/drivers/firewire/fw-sbp2.c
@@ -762,9 +762,10 @@ static void sbp2_release_target(struct k
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);
@@ -886,8 +887,6 @@ static void sbp2_login(struct work_struc
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) {
--
Stefan Richter
-=====-==--- --=- =---=
http://arcgraph.de/sr/
next prev parent reply other threads:[~2008-02-17 18:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-17 13:56 [PATCH] firewire: fw-sbp2: fix NULL pointer deref in slave_alloc Stefan Richter
2008-02-17 13:57 ` [PATCH] ieee1394: sbp2: fix rescan-scsi-bus Stefan Richter
2008-02-17 16:03 ` James Bottomley
2008-02-17 17:58 ` Stefan Richter
2008-02-17 21:08 ` Stefan Richter
2008-02-17 17:44 ` [PATCH] firewire: fw-sbp2: fix NULL pointer deref in slave_alloc Stefan Richter
2008-02-17 18:17 ` Stefan Richter [this message]
2008-02-19 8:05 ` [PATCH update] firewire: fw-sbp2: fix NULL pointer deref in scsi_remove_device Stefan Richter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tkrat.bc89a18c9ce7df0b@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox