From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: David Decotigny <decot@googlers.com>
Cc: linux-scsi@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scsi: avoid use of reclaimed reference
Date: Tue, 12 Nov 2013 22:46:42 -0800 [thread overview]
Message-ID: <1384325202.3149.8.camel@dabdike.int.hansenpartnership.com> (raw)
In-Reply-To: <CAG88wWZyodGU7AmTX=wYWn5igr-ySm_HLs0uA1iO+Fxq3msRnA@mail.gmail.com>
On Tue, 2013-11-12 at 18:09 -0800, David Decotigny wrote:
> I was considering the following scenario wherein the "if
> (scsi_device_created(sdev))" test at the end would test garbage at
> best (or unmapped data):
Well, no, the counting isn't right:
> if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { // not found
> sdev = scsi_alloc_sdev(starget, 0, NULL); // -> ref cnt = 2
1
> if (scsi_device_get(sdev)) { // -> ref cnt = 3
2
> }
> ...
> }
> ...
> res = scsi_probe_and_add_lun(starget, // ->
> ref cnt = 1
No idea what you think here, where were the other puts? If starget,lun
is sdev, then the count goes to 3 here otherwise it stays at 2 if it
isn't reported in the scan.
...
> scsi_device_put(sdev); // -> reclaimed
No, it goes to either 2 or 1 here. If it goes to 1 it's because the
sdev was never probed and thus it remains in the created state.
> if (scsi_device_created(sdev)) // test on garbage or unmapped data (#PF)
Which means this test passes and it gets garbage collected by
__scsi_remove_device(). Otherwise we exit with refcount 2.
James
next prev parent reply other threads:[~2013-11-13 6:46 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
2013-11-13 1:57 ` James Bottomley
2013-11-13 2:09 ` David Decotigny
2013-11-13 6:46 ` James Bottomley [this message]
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=1384325202.3149.8.camel@dabdike.int.hansenpartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=decot@googlers.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®