iop-adma, dmaengine: misplaced curly brackets?
PATCH 1/1 iop-adma, dmaengine: misplaced curly brackets?
I observed this by code inspection, and it was not tested in any way, but aren't the curly brackets below wrong?
please review. ------------------------------>8-------------8<--------------------------------- Misplaced curly brackets.
--- drivers/dma/iop-adma.c | 16 ++++++++-------- drivers/dma/mv_xor.c | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-)
drivers/dma/iop-adma.c +8 -8
@@ -928,19 +928,19 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)for (src_idx =0 ; src_idx <IOP_ADMA_NUM_SRC_TEST ; src_idx++) { xor_srcs[src_idx] =alloc_page (GFP_KERNEL ); -if (!xor_srcs[src_idx]) -while (src_idx--) { +if (!xor_srcs[src_idx]) { +while (src_idx--)__free_page (xor_srcs[src_idx]); -return -ENOMEM ; - } +return -ENOMEM ; + } } dest =alloc_page (GFP_KERNEL ); -if (!dest) -while (src_idx--) { +if (!dest) { +while (src_idx--)__free_page (xor_srcs[src_idx]); -return -ENOMEM ; - } +return -ENOMEM ; + }/* Fill in src buffers */ for (src_idx =0 ; src_idx <IOP_ADMA_NUM_SRC_TEST ; src_idx++) {
drivers/dma/mv_xor.c +8 -8
@@ -1019,19 +1019,19 @@ mv_xor_xor_self_test(struct mv_xor_device *device)for (src_idx =0 ; src_idx <MV_XOR_NUM_SRC_TEST ; src_idx++) { xor_srcs[src_idx] =alloc_page (GFP_KERNEL ); -if (!xor_srcs[src_idx]) -while (src_idx--) { +if (!xor_srcs[src_idx]) { +while (src_idx--)__free_page (xor_srcs[src_idx]); -return -ENOMEM ; - } +return -ENOMEM ; + } } dest =alloc_page (GFP_KERNEL ); -if (!dest) -while (src_idx--) { +if (!dest) { +while (src_idx--)__free_page (xor_srcs[src_idx]); -return -ENOMEM ; - } +return -ENOMEM ; + }/* Fill in src buffers */ for (src_idx =0 ; src_idx <MV_XOR_NUM_SRC_TEST ; src_idx++) {
Quoted 9 lines · Roel Kluin
I observed this by code inspection, and it was not tested in any way, but aren't the curly brackets below wrong?
please review. ------------------------------>8-------------8<--------------------------------- Misplaced curly brackets.
Signed-off-by Roel Kluin <[email protected]>---
Yes, static analysis caught this error here recently as well. I have applied your patch with a fixed up changelog:
commit d2076514c9ea68e7fef21158c1cdb8b244bfe5f2
Author: Roel Kluin <[email protected]> Date: Wed Feb 25 13:56:21 2009 +0100
iop-adma, mv_xor: fix mem leak on self-test setup failure
iop_adma_zero_sum_self_test has the brackets in the wrong place for the setup failure deallocation path. This error was duplicated in mv_xor_xor_self_test.
Thanks,
Dan