All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Anderson <andmike@us.ibm.com>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: linux-scsi@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 1/2] sas transport: ref count update
Date: Mon, 27 Mar 2006 09:37:28 -0800	[thread overview]
Message-ID: <20060327173728.GB29353@us.ibm.com> (raw)
In-Reply-To: <1143304763.3049.34.camel@mulgrave.il.steeleye.com>

James Bottomley <James.Bottomley@SteelEye.com> wrote:
> On Fri, 2006-03-24 at 19:56 -0800, Mike Anderson wrote:
> > Can I get your comment(s) on this change.
> 
> This looks correct as far as it goes, but it's not complete.
> sas_phy_free() and sas_rphy_free() now do too many parent puts with this
> change (actually, two too many in each case, which looks like a bug in
> the original code).  There also looks to be two spurious puts in the
> rphy (for expander and end device) allocation error paths (again, a bug
> in the original code).

ok, here is an updated patch that covers these cases also. I moved to
using the releases functions in the *_free() cases also as it seems like a
good idea to use the release functions if you can. I have compiled and
tested it on a aic based system, but it does not call the free functions.

-andmike
--
Michael Anderson
andmike@us.ibm.com

Fix puts so that release functions will be called.

Signed-off-by: Mike Anderson <andmike@us.ibm.com>

 drivers/scsi/scsi_transport_sas.c |   30 ++++++------------------------
 1 files changed, 6 insertions(+), 24 deletions(-)

Index: aic94xx-sas-2.6-patched/drivers/scsi/scsi_transport_sas.c
===================================================================
--- aic94xx-sas-2.6-patched.orig/drivers/scsi/scsi_transport_sas.c	2006-03-24 13:58:17.000000000 -0800
+++ aic94xx-sas-2.6-patched/drivers/scsi/scsi_transport_sas.c	2006-03-27 09:23:43.000000000 -0800
@@ -406,8 +406,6 @@ struct sas_phy *sas_phy_alloc(struct dev
 	if (!phy)
 		return NULL;
 
-	get_device(parent);
-
 	phy->number = number;
 
 	device_initialize(&phy->dev);
@@ -459,10 +457,7 @@ EXPORT_SYMBOL(sas_phy_add);
 void sas_phy_free(struct sas_phy *phy)
 {
 	transport_destroy_device(&phy->dev);
-	put_device(phy->dev.parent);
-	put_device(phy->dev.parent);
-	put_device(phy->dev.parent);
-	kfree(phy);
+	put_device(&phy->dev);
 }
 EXPORT_SYMBOL(sas_phy_free);
 
@@ -484,7 +479,7 @@ sas_phy_delete(struct sas_phy *phy)
 	transport_remove_device(dev);
 	device_del(dev);
 	transport_destroy_device(dev);
-	put_device(dev->parent);
+	put_device(dev);
 }
 EXPORT_SYMBOL(sas_phy_delete);
 
@@ -800,7 +795,6 @@ struct sas_rphy *sas_end_device_alloc(st
 
 	rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
 	if (!rdev) {
-		put_device(&parent->dev);
 		return NULL;
 	}
 
@@ -836,7 +830,6 @@ struct sas_rphy *sas_expander_alloc(stru
 
 	rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
 	if (!rdev) {
-		put_device(&parent->dev);
 		return NULL;
 	}
 
@@ -910,6 +903,7 @@ EXPORT_SYMBOL(sas_rphy_add);
  */
 void sas_rphy_free(struct sas_rphy *rphy)
 {
+	struct device *dev = &rphy->dev;
 	struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent);
 	struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);
 
@@ -917,21 +911,9 @@ void sas_rphy_free(struct sas_rphy *rphy
 	list_del(&rphy->list);
 	mutex_unlock(&sas_host->lock);
 
-	transport_destroy_device(&rphy->dev);
-	put_device(rphy->dev.parent);
-	put_device(rphy->dev.parent);
-	put_device(rphy->dev.parent);
-	if (rphy->identify.device_type == SAS_END_DEVICE) {
-		struct sas_end_device *edev = rphy_to_end_device(rphy);
-
-		kfree(edev);
-	} else {
-		/* must be expander */
-		struct sas_expander_device *edev =
-			rphy_to_expander_device(rphy);
+	transport_destroy_device(dev);
 
-		kfree(edev);
-	}
+	put_device(dev);
 }
 EXPORT_SYMBOL(sas_rphy_free);
 
@@ -971,7 +953,7 @@ sas_rphy_delete(struct sas_rphy *rphy)
 
 	parent->rphy = NULL;
 
-	put_device(&parent->dev);
+	put_device(dev);
 }
 EXPORT_SYMBOL(sas_rphy_delete);
 

  reply	other threads:[~2006-03-27 17:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22 21:41 [PATCH 0/2] aic94xx / sas: ref count update Mike Anderson
2006-03-22 21:42 ` [PATCH 1/2] sas transport: " Mike Anderson
2006-03-25  3:56   ` Mike Anderson
2006-03-25 16:39     ` James Bottomley
2006-03-27 17:37       ` Mike Anderson [this message]
2006-03-28 15:08         ` Christoph Hellwig
2006-03-22 21:44 ` [PATCH 2/2] aic94xx: " Mike Anderson

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=20060327173728.GB29353@us.ibm.com \
    --to=andmike@us.ibm.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=hch@lst.de \
    --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.