libiscsi: fix iscsi pool error path
PATCH 1/1 libiscsi: fix iscsi pool error path
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.
---
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(-)
drivers/scsi/libiscsi.c +2 -3
@@ -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);
Signature · 2 lines
Jean Delvare Suse L3
Quoted 10 lines · Jean Delvare
Memory freeing in
iscsi_pool_free()looks wrong to me. Eitherq->poolcan 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 whereq->poolis NULL is on early error iniscsi_pool_init(). One possible way to fix the bug is thus to not calliscsi_pool_free()in this case (nothing needs to be freed anyway) and then we can get rid of theq->poolcheck.Signed-off-by Jean Delvare <[email protected]>Acked-by Mike Christie <[email protected]>
James,
If you are scooping up late fixes for 2.6.29-rc, then please take this if it qualifies. It is not a regression, but a simple bug fix that can be hit in situations where there is small amounts of memory (for some reason common in virtual machine setups a lot).