From: Jens Axboe <axboe@suse.de>
To: linux-scsi@vger.kernel.org
Cc: James Bottomley <James.Bottomley@steeleye.com>
Subject: [PATCH] scsi_allocate_request() reference
Date: Mon, 21 Mar 2005 14:26:06 +0100 [thread overview]
Message-ID: <20050321132604.GA25452@suse.de> (raw)
Hi,
scsi_allocate_request() doesn't hold a reference to the device that it
points to, that is not good. This patch fixes that up.
Signed-off-by: Jens Axboe <axboe@suse.de>
===== drivers/scsi/scsi.c 1.157 vs edited =====
--- 1.157/drivers/scsi/scsi.c 2005-03-03 09:22:17 +01:00
+++ edited/drivers/scsi/scsi.c 2005-03-21 14:24:27 +01:00
@@ -132,7 +132,11 @@
const int offset = ALIGN(sizeof(struct scsi_request), 4);
const int size = offset + sizeof(struct request);
struct scsi_request *sreq;
-
+
+
+ if (!get_device(&sdev->sdev_gendev))
+ return NULL;
+
sreq = kmalloc(size, gfp_mask);
if (likely(sreq != NULL)) {
memset(sreq, 0, size);
@@ -141,7 +145,8 @@
sreq->sr_host = sdev->host;
sreq->sr_magic = SCSI_REQ_MAGIC;
sreq->sr_data_direction = DMA_BIDIRECTIONAL;
- }
+ } else
+ put_device(&sdev->sdev_gendev);
return sreq;
}
@@ -184,6 +189,10 @@
void scsi_release_request(struct scsi_request *sreq)
{
__scsi_release_request(sreq);
+
+ if (sreq->sr_device)
+ put_device(&sreq->sr_device->sdev_gendev);
+
kfree(sreq);
}
EXPORT_SYMBOL(scsi_release_request);
--
Jens Axboe
next reply other threads:[~2005-03-21 13:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-21 13:26 Jens Axboe [this message]
2005-03-21 15:09 ` [PATCH] scsi_allocate_request() reference James Bottomley
2005-03-21 16:57 ` Jens Axboe
2005-03-21 23:51 ` Tejun Heo
2005-03-22 11:17 ` Jens Axboe
2005-03-22 15:34 ` 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=20050321132604.GA25452@suse.de \
--to=axboe@suse.de \
--cc=James.Bottomley@steeleye.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.