From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762369AbZD2Wb2 (ORCPT ); Wed, 29 Apr 2009 18:31:28 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755354AbZD2WVd (ORCPT ); Wed, 29 Apr 2009 18:21:33 -0400 Received: from kroah.org ([198.145.64.141]:40469 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758981AbZD2WV3 (ORCPT ); Wed, 29 Apr 2009 18:21:29 -0400 X-Mailbox-Line: From gregkh@mini.kroah.org Wed Apr 29 15:09:27 2009 Message-Id: <20090429220927.114222967@mini.kroah.org> User-Agent: quilt/0.48-1 Date: Wed, 29 Apr 2009 15:07:26 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Jean Delvare , Mike Christie , James Bottomley , Chris Wright Subject: [patch 27/58] SCSI: libiscsi: fix iscsi pool error path References: <20090429220659.339950874@mini.kroah.org> Content-Disposition: inline; filename=0052-SCSI-libiscsi-fix-iscsi-pool-error-path.patch In-Reply-To: <20090429221657.GA11765@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2.6.27-stable review patch. If anyone has any objections, please let us know. ------------------ From: Jean Delvare upstream commit: f474a37bc48667595b5653a983b635c95ed82a3b 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 Signed-off-by: Mike Christie Signed-off-by: James Bottomley Signed-off-by: Chris Wright Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/libiscsi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1807,7 +1807,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); @@ -1842,8 +1842,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);