linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John W. Linville" <linville@tuxdriver.com>
To: linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, jgarzik@pobox.com
Subject: [patch libata-dev-2.6 1/5] libata: fix command queue leak when xlat_func fails
Date: Fri, 18 Feb 2005 14:50:29 -0500	[thread overview]
Message-ID: <20050218195027.GB3197@tuxdriver.com> (raw)

ata_scsi_translate allocates from the libata command queue by calling
ata_scsi_qc_new.  If xlat_func returns non-zero, control jumps to
err_out which fails to free the allocated command.  Fix is to add a
new API to free unused commands.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---

 drivers/scsi/libata-core.c |   18 ++++++++++++++++++
 drivers/scsi/libata-scsi.c |    1 +
 drivers/scsi/libata.h      |    1 +
 3 files changed, 20 insertions(+)

--- sata-smart-2.6/drivers/scsi/libata-scsi.c.bugfix	2005-02-17 16:47:04.992924055 -0500
+++ sata-smart-2.6/drivers/scsi/libata-scsi.c	2005-02-17 16:48:48.265138198 -0500
@@ -967,6 +967,7 @@ static void ata_scsi_translate(struct at
 	return;
 
 err_out:
+	ata_qc_free(qc);
 	ata_bad_cdb(cmd, done);
 	DPRINTK("EXIT - badcmd\n");
 }
--- sata-smart-2.6/drivers/scsi/libata-core.c.bugfix	2005-02-17 16:46:44.659638355 -0500
+++ sata-smart-2.6/drivers/scsi/libata-core.c	2005-02-17 16:48:48.269137664 -0500
@@ -2687,6 +2687,24 @@ static void __ata_qc_complete(struct ata
 }
 
 /**
+ *	ata_qc_free - free unused ata_queued_cmd
+ *	@qc: Command to complete
+ *
+ *	Designed to free unused ata_queued_cmd object
+ *	in case something prevents using it.
+ *
+ *	LOCKING:
+ *
+ */
+void ata_qc_free(struct ata_queued_cmd *qc)
+{
+	assert(qc != NULL);	/* ata_qc_from_tag _might_ return NULL */
+	assert(qc->waiting == NULL);	/* nothing should be waiting */
+
+	__ata_qc_complete(qc);
+}
+
+/**
  *	ata_qc_complete - Complete an active ATA command
  *	@qc: Command to complete
  *	@drv_stat: ATA status register contents
--- sata-smart-2.6/drivers/scsi/libata.h.bugfix	2005-02-17 16:46:47.630241808 -0500
+++ sata-smart-2.6/drivers/scsi/libata.h	2005-02-17 16:48:48.306132726 -0500
@@ -37,6 +37,7 @@ struct ata_scsi_args {
 /* libata-core.c */
 extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
 				      struct ata_device *dev);
+extern void ata_qc_free(struct ata_queued_cmd *qc);
 extern int ata_qc_issue(struct ata_queued_cmd *qc);
 extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
 extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
-- 
John W. Linville
linville@tuxdriver.com

             reply	other threads:[~2005-02-18 19:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-18 19:50 John W. Linville [this message]
2005-02-18 19:55 ` [patch libata-dev-2.6 2/5] libata: sync SMART ioctls with ATA pass thru spec (T10/04-262r7) John W. Linville
2005-02-18 20:03   ` [patch libata-dev-2.6 3/5] libata: filter SET_FEATURES - XFER MODE from ATA pass thru John W. Linville
2005-02-18 20:06     ` [patch libata-dev-2.6 4/5] libata: minor style changes in ata_scsi_pass_thru John W. Linville
2005-02-18 20:16       ` [patch libata-dev-2.6 5/5] libata: update ATA pass thru opcodes John W. Linville
2005-02-18 20:50 ` [patch libata-dev-2.6 1/5] libata: fix command queue leak when xlat_func fails Jeff Garzik

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=20050218195027.GB3197@tuxdriver.com \
    --to=linville@tuxdriver.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).