public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Hicks <mort@wildopensource.com>
To: linux-scsi@vger.kernel.org
Cc: James.Bottomley@SteelEye.com
Subject: [PATCH] Call slave_destroy in scsi_alloc_sdev error path
Date: Fri, 9 Jan 2004 11:02:44 -0500	[thread overview]
Message-ID: <20040109160244.GL30627@localhost> (raw)

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]


Hello,

This patch fixes a potential memory leak in scsi_alloc_sdev.

If slave_alloc kmallocs memory and the get_device() (around line 245)
fails then we goto the error path.  The error path never calls
slave_destroy.

This patch fixes this problem.
mh

-- 
Martin Hicks                Wild Open Source Inc.
mort@wildopensource.com     613-266-2296

[-- Attachment #2: scsi_slave_destroy.diff --]
[-- Type: text/plain, Size: 1281 bytes --]

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1491  -> 1.1492 
#	drivers/scsi/scsi_scan.c	1.114   -> 1.115  
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/09	mort@green.i.bork.org	1.1492
# We should call slave_destroy on the error path if slave_alloc
# has already been called and has succeeded in scsi_alloc_sdev()
# --------------------------------------------
#
diff -Nru a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c	Fri Jan  9 10:20:43 2004
+++ b/drivers/scsi/scsi_scan.c	Fri Jan  9 10:20:43 2004
@@ -254,7 +254,7 @@
 			 "%d:%d:%d:%d", sdev->host->host_no,
 			 sdev->channel, sdev->id, sdev->lun);
 	} else
-		goto out_free_queue;
+		goto out_cleanup_slave;
 
 	/*
 	 * If there are any same target siblings, add this to the
@@ -283,6 +283,9 @@
 	spin_unlock_irqrestore(shost->host_lock, flags);
 	return sdev;
 
+out_cleanup_slave:
+	if (shost->hostt->slave_destroy)
+		shost->hostt->slave_destroy(sdev);
 out_free_queue:
 	scsi_free_queue(sdev->request_queue);
 out_free_dev:

                 reply	other threads:[~2004-01-09 16:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20040109160244.GL30627@localhost \
    --to=mort@wildopensource.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox