Commit fea3860d authored by Gargi Sharma's avatar Gargi Sharma Committed by Greg Kroah-Hartman

staging: greybus: loopback_test: fix device-name leak

All the device names were being always leaked. Also,
illegal free was being called upon namelist[n] which
was coincidentally NULL. The pointer to dirent structures
must be individually freed before freeing the pointer array.

Coccinelle Script:
@@
expression arr,ex1,ex2;
@@

for(ex1 = 0; ex1 < ex2; ex1++) { <...
  arr[
- ex2
+ ex1
  ]
  ...> }
Signed-off-by: default avatarGargi Sharma <gs051095@gmail.com>
Reviewed by: Johan Hovold <johan@kernel.org>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 95ee706e
......@@ -636,7 +636,7 @@ int find_loopback_devices(struct loopback_test *t)
ret = 0;
done:
for (i = 0; i < n; i++)
free(namelist[n]);
free(namelist[i]);
free(namelist);
baddir:
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment