libsrp: fix memory leak in srp_ring_free()
PATCH 1/1 libsrp: fix memory leak in srp_ring_free()
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).
diff -uprN orig/linux-2.6.30/drivers/scsi/libsrp.c linux-2.6.30/drivers/scsi/libsrp.c
drivers/scsi/libsrp.c renamed from linux-2.6.30/drivers/scsi/libsrp.c +1 -0
@@ -124,6 +124,7 @@ static void srp_ring_free(struct devicedma_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,
Quoted 8 lines · On Sun, 30 Aug 2009 12:36:48 +0200 Bart Van Assche <[email protected]>…
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()andsrp_target_free()) makes it clear thatsrp_ring_free()should deallocate the ring pointer itself. Furthermore, the patch below makessrp_ring_free()deallocate all memory allocated bysrp_ring_alloc().
Quoted 6 lines
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 <[email protected]>Cc James Bottomley <[email protected]>Cc FUJITA Tomonori <[email protected]>
Better to add:
Thanks,
Quoted 19 lines · FUJITA Tomonori
Quoted 8 lines · On Sun, 30 Aug 2009 12:36:48 +0200 Bart Van Assche <[email protected]>…
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()andsrp_target_free()) makes it clear thatsrp_ring_free()should deallocate the ring pointer itself. Furthermore, the patch below makessrp_ring_free()deallocate all memory allocated bysrp_ring_alloc().Quoted 6 lines
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 <[email protected]>Cc James Bottomley <[email protected]>Cc FUJITA Tomonori <[email protected]>
Quoted 5 lines
Acked-by FUJITA Tomonori <[email protected]>Better to add:
Thanks for the review. I will submit this patch to [email protected] as soon as it has been committed. Patches are only accepted for backporting after they have been committed in the mainline kernel.
Bart.
Quoted 23 lines · On Sat, 5 Sep 2009 11:34:40 +0200 Bart Van Assche <[email protected]>…
Quoted 21 lines · FUJITA Tomonori
Quoted 8 lines · On Sun, 30 Aug 2009 12:36:48 +0200 Bart Van Assche <[email protected]>…
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()andsrp_target_free()) makes it clear thatsrp_ring_free()should deallocate the ring pointer itself. Furthermore, the patch below makessrp_ring_free()deallocate all memory allocated bysrp_ring_alloc().Quoted 6 lines
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 <[email protected]>Cc James Bottomley <[email protected]>Cc FUJITA Tomonori <[email protected]>Acked-by FUJITA Tomonori <[email protected]>
Quoted 7 lines
Quoted 3 lines
Better to add:
Thanks for the review. I will submit this patch to [email protected] as soon as it has been committed. Patches are only accepted for backporting after they have been committed in the mainline kernel.
You don't need to submit a patch to [email protected] if you put 'Cc:
[email protected]' tag in a commit log; the patch will be sent to [email protected] automatically after the the patch is merged into mainline.
Quoted 5 lines · FUJITA Tomonori
[...]
You don't need to submit a patch to [email protected] if you put 'Cc:
[email protected]' tag in a commit log; the patch will be sent to [email protected] automatically after the the patch is merged into mainline.
I have just submitted a second revision of this patch with the 'Cc:
[email protected]' added.
Bart.