public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: Jean Delvare <jdelvare@suse.de>
Cc: stable@kernel.org, Mike Christie <michaelc@cs.wisc.edu>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [stable] [PATCH] [SCSI] libiscsi: fix iscsi pool error path
Date: Mon, 30 Mar 2009 18:44:58 +0000	[thread overview]
Message-ID: <20090330184458.GB11116@hera.kernel.org> (raw)
In-Reply-To: <200903291119.42080.jdelvare@suse.de>

* Jean Delvare (jdelvare@suse.de) wrote:
> --- linux-2.6.29-rc5.orig/drivers/scsi/libiscsi.c	2009-01-29 08:27:19.000000000 +0100
> +++ linux-2.6.29-rc5/drivers/scsi/libiscsi.c	2009-02-16 21:19:14.000000000 +0100
> @@ -1944,7 +1944,7 @@ iscsi_pool_init(struct iscsi_pool *q, in
>  		num_arrays++;
>  	q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
>  	if (q->pool == NULL)
> -		goto enomem;
> +		return -ENOMEM;
>  
>  	q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
>  			      GFP_KERNEL, NULL);
> @@ -1979,8 +1979,7 @@ void iscsi_pool_free(struct iscsi_pool *
>  
>  	for (i = 0; i < q->max; i++)
>  		kfree(q->pool[i]);
> -	if (q->pool)
> -		kfree(q->pool);
> +	kfree(q->pool);
>  	kfree(q->queue);

AFAICT, This is still broken.

thanks,
-chris
--

Subject: [PATCH] libiscsi: fix error path on iscsi_pool_init

From: Chris Wright <chrisw@sous-sol.org>

I'm not all that keen on kfifo_init returning ERR_PTR, but...
q->queue could be ERR_PTR(-ENOMEM) which will break unwinding
on error.  Make iscsi_pool_free more defensive.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index dfaa8ad..2f4df53 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1995,7 +1995,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 		num_arrays++;
 	q->pool = kzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
 	if (q->pool == NULL)
-		return -ENOMEM;
+		goto enomem;
 
 	q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
 			      GFP_KERNEL, NULL);
@@ -2028,10 +2028,13 @@ void iscsi_pool_free(struct iscsi_pool *q)
 {
 	int i;
 
-	for (i = 0; i < q->max; i++)
-		kfree(q->pool[i]);
-	kfree(q->pool);
-	kfree(q->queue);
+	if (q->pool) {
+		for (i = 0; i < q->max; i++)
+			kfree(q->pool[i]);
+		kfree(q->pool);
+		if (!IS_ERR(q->queue))
+			kfree(q->queue);
+	}
 }
 EXPORT_SYMBOL_GPL(iscsi_pool_free);
 

       reply	other threads:[~2009-03-30 18:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200903291119.42080.jdelvare@suse.de>
2009-03-30 18:44 ` Chris Wright [this message]
2009-03-30 18:49   ` [PATCH] libsrp: free kfifo struct in srp_iu_pool_free Chris Wright
2009-03-30 19:38     ` Jean Delvare
2009-03-30 19:34   ` [stable] [PATCH] [SCSI] libiscsi: fix iscsi pool error path Jean Delvare
2009-03-30 19:43     ` Chris Wright
2009-03-31  6:38     ` Mike Christie

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=20090330184458.GB11116@hera.kernel.org \
    --to=chrisw@sous-sol.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=jdelvare@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    --cc=stable@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