mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Decotigny <decot@googlers.com>
To: linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-kernel@vger.kernel.org,
	David Decotigny <decot@googlers.com>
Subject: [PATCH] scsi: avoid use of reclaimed reference
Date: Tue, 12 Nov 2013 17:10:19 -0800	[thread overview]
Message-ID: <643cda2192c25962f37c8bba65e22f70a57167d0.1384304973.git.decot@googlers.com> (raw)
In-Reply-To: <cover.1384304973.git.decot@googlers.com>

This patch avoids to use an object after it was potentially reclaimed
by scsi_device_put().

Signed-off-by: David Decotigny <decot@googlers.com>
---
 drivers/scsi/scsi_scan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 307a811..16e4a44 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1498,12 +1498,14 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
  out_err:
 	kfree(lun_data);
  out:
-	scsi_device_put(sdev);
-	if (scsi_device_created(sdev))
+	if (scsi_device_created(sdev)) {
 		/*
 		 * the sdev we used didn't appear in the report luns scan
 		 */
 		__scsi_remove_device(sdev);
+	}
+
+	scsi_device_put(sdev);
 	return ret;
 }
 
-- 
1.8.4.1


       reply	other threads:[~2013-11-13  1:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1384304973.git.decot@googlers.com>
2013-11-13  1:10 ` David Decotigny [this message]
2013-11-13  1:57   ` James Bottomley
2013-11-13  2:09     ` David Decotigny
2013-11-13  6:46       ` James Bottomley
2013-11-13 12:06   ` Bart Van Assche
2013-11-14  2:50     ` David Decotigny
2013-11-14  6:15       ` James Bottomley

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=643cda2192c25962f37c8bba65e22f70a57167d0.1384304973.git.decot@googlers.com \
    --to=decot@googlers.com \
    --cc=JBottomley@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®