All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Call slave_destroy in scsi_alloc_sdev error path
@ 2004-01-09 16:02 Martin Hicks
  0 siblings, 0 replies; only message in thread
From: Martin Hicks @ 2004-01-09 16:02 UTC (permalink / raw)
  To: linux-scsi; +Cc: James.Bottomley

[-- 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:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-01-09 16:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-09 16:02 [PATCH] Call slave_destroy in scsi_alloc_sdev error path Martin Hicks

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.