From: James Bottomley <James.Bottomley@steeleye.com>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Cc: Russell King <rmk@arm.linux.org.uk>
Subject: [PATCH] fix for memory leak in scsi_prep_fn
Date: 28 Jan 2003 12:32:45 -0600 [thread overview]
Message-ID: <1043778768.2991.74.camel@mulgrave> (raw)
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
This should fix the memory leak Russell King spotted if command
initialisation fails in the request prep function.
The patch is against the scsi-combined-2.5 bkbits.net repository.
James
[-- Attachment #2: Type: text/plain, Size: 1176 bytes --]
===== drivers/scsi/scsi_lib.c 1.63 vs edited =====
--- 1.63/drivers/scsi/scsi_lib.c Tue Jan 28 10:19:35 2003
+++ edited/drivers/scsi/scsi_lib.c Tue Jan 28 12:29:45 2003
@@ -796,6 +796,8 @@
struct Scsi_Device_Template *STpnt;
Scsi_Cmnd *SCpnt;
Scsi_Device *SDpnt;
+ int ret;
+
SDpnt = (Scsi_Device *) q->queuedata;
BUG_ON(!SDpnt);
@@ -862,8 +864,6 @@
*/
if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) {
- int ret;
-
/*
* This will do a couple of things:
* 1) Fill in the actual SCSI command.
@@ -884,19 +884,27 @@
* required).
*/
if ((ret = scsi_init_io(SCpnt)))
- return ret;
+ goto fail_release_cmd;
/*
* Initialize the actual SCSI command for this request.
*/
if (!STpnt->init_command(SCpnt)) {
- scsi_release_buffers(SCpnt);
- return BLKPREP_KILL;
+ ret = BLKPREP_KILL;
+ goto fail_release_buffers;
}
}
/* The request is now prepped, no need to come back here */
req->flags |= REQ_DONTPREP;
return BLKPREP_OK;
+
+ fail_release_buffers:
+ scsi_release_buffers(SCpnt);
+
+ fail_release_cmd:
+ scsi_put_command(SCpnt);
+
+ return ret;
}
/*
next reply other threads:[~2003-01-28 18:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-28 18:32 James Bottomley [this message]
2003-01-28 18:52 ` [PATCH] fix for memory leak in scsi_prep_fn 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=1043778768.2991.74.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=linux-scsi@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
/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