Skip to content

Commit

Permalink
iop-adma, mv_xor: fix mem leak on self-test setup failure
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Roel Kluin authored and Dan Williams committed Mar 4, 2009
1 parent 900325a commit a09b09a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions drivers/dma/iop-adma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
16 changes: 8 additions & 8 deletions drivers/dma/mv_xor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit a09b09a

Please sign in to comment.