Commit a09b09ae51ace43d28cd9bc1c8bb97986f2b55a6

Authored by Roel Kluin
Committed by Dan Williams
1 parent 900325a6ce

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.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Showing 2 changed files with 16 additions and 16 deletions Side-by-side Diff

drivers/dma/iop-adma.c
... ... @@ -928,19 +928,19 @@
928 928  
929 929 for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) {
930 930 xor_srcs[src_idx] = alloc_page(GFP_KERNEL);
931   - if (!xor_srcs[src_idx])
932   - while (src_idx--) {
  931 + if (!xor_srcs[src_idx]) {
  932 + while (src_idx--)
933 933 __free_page(xor_srcs[src_idx]);
934   - return -ENOMEM;
935   - }
  934 + return -ENOMEM;
  935 + }
936 936 }
937 937  
938 938 dest = alloc_page(GFP_KERNEL);
939   - if (!dest)
940   - while (src_idx--) {
  939 + if (!dest) {
  940 + while (src_idx--)
941 941 __free_page(xor_srcs[src_idx]);
942   - return -ENOMEM;
943   - }
  942 + return -ENOMEM;
  943 + }
944 944  
945 945 /* Fill in src buffers */
946 946 for (src_idx = 0; src_idx < IOP_ADMA_NUM_SRC_TEST; src_idx++) {
drivers/dma/mv_xor.c
... ... @@ -1019,19 +1019,19 @@
1019 1019  
1020 1020 for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) {
1021 1021 xor_srcs[src_idx] = alloc_page(GFP_KERNEL);
1022   - if (!xor_srcs[src_idx])
1023   - while (src_idx--) {
  1022 + if (!xor_srcs[src_idx]) {
  1023 + while (src_idx--)
1024 1024 __free_page(xor_srcs[src_idx]);
1025   - return -ENOMEM;
1026   - }
  1025 + return -ENOMEM;
  1026 + }
1027 1027 }
1028 1028  
1029 1029 dest = alloc_page(GFP_KERNEL);
1030   - if (!dest)
1031   - while (src_idx--) {
  1030 + if (!dest) {
  1031 + while (src_idx--)
1032 1032 __free_page(xor_srcs[src_idx]);
1033   - return -ENOMEM;
1034   - }
  1033 + return -ENOMEM;
  1034 + }
1035 1035  
1036 1036 /* Fill in src buffers */
1037 1037 for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) {