From: Jean Delvare <jdelvare@suse.de>
To: linux-scsi@vger.kernel.org
Cc: Mike Christie <michaelc@cs.wisc.edu>
Subject: [PATCH] [SCSI] libiscsi: fix iscsi pool error path
Date: Wed, 18 Feb 2009 20:35:23 +0100 [thread overview]
Message-ID: <200902182035.23939.jdelvare@suse.de> (raw)
Memory freeing in iscsi_pool_free() looks wrong to me. Either q->pool
can be NULL and this should be tested before dereferencing it, or it
can't be NULL and it shouldn't be tested at all. As far as I can see,
the only case where q->pool is NULL is on early error in
iscsi_pool_init(). One possible way to fix the bug is thus to not
call iscsi_pool_free() in this case (nothing needs to be freed anyway)
and then we can get rid of the q->pool check.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Mike Christie <michaelc@cs.wisc.edu>
---
Another possible fix is to move the q->pool check one line up. Both
are fine with me.
drivers/scsi/libiscsi.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- 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);
}
EXPORT_SYMBOL_GPL(iscsi_pool_free);
--
Jean Delvare
Suse L3
next reply other threads:[~2009-02-18 19:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-18 19:35 Jean Delvare [this message]
2009-02-19 17:26 ` [PATCH] [SCSI] libiscsi: fix iscsi pool error path 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=200902182035.23939.jdelvare@suse.de \
--to=jdelvare@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
/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