]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
[SCSI] libsrp: fix memory leak in srp_ring_free()
authorBart Van Assche <bart.vanassche@gmail.com>
Sun, 30 Aug 2009 10:36:48 +0000 (12:36 +0200)
committerJames Bottomley <James.Bottomley@suse.de>
Sat, 12 Sep 2009 14:35:34 +0000 (09:35 -0500)
This patch fixes a memory leak in the libsrp function srp_ring_free().
It is not documented whether or not this function should free the ring
pointer itself. But the source code of the callers of this function
(srp_target_alloc() and srp_target_free()) makes it clear that
srp_ring_free() should deallocate the ring pointer itself. Furthermore,
the patch below makes srp_ring_free() deallocate all memory allocated by
srp_ring_alloc().

This patch affects the ibmvstgt driver, which is the only in-tree driver
that calls the srp_ring_free() function (indirectly).

Signed-off-by: Bart Van Assche <bart.vanassche@gmail.com>
Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/libsrp.c

index 2742ae8a3d091a13b989fb4f5a7de57e4f7d0490..9ad38e81e343ee1b9d419b175f266131dbceb0cf 100644 (file)
@@ -124,6 +124,7 @@ static void srp_ring_free(struct device *dev, struct srp_buf **ring, size_t max,
                dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma);
                kfree(ring[i]);
        }
+       kfree(ring);
 }
 
 int srp_target_alloc(struct srp_target *target, struct device *dev,