All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: greybus: loopback_test: fix device-name leak
@ 2017-02-21 19:06 Gargi Sharma
  2017-02-21 19:45 ` Johan Hovold
  2017-02-21 19:50 ` Johan Hovold
  0 siblings, 2 replies; 6+ messages in thread
From: Gargi Sharma @ 2017-02-21 19:06 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, johan, elder, Gargi Sharma

Change array index from the loop bound variable to loop index.
Memory leak was occuring whenever there was more than one
loopback device. 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: Gargi Sharma <gs051095@gmail.com>
---
Changes in v2:
	-Made the commit message clearer.
---
 drivers/staging/greybus/tools/loopback_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c
index 18d7a3d..1c01833 100644
--- a/drivers/staging/greybus/tools/loopback_test.c
+++ b/drivers/staging/greybus/tools/loopback_test.c
@@ -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;
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-22 10:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-21 19:06 [PATCH v2] staging: greybus: loopback_test: fix device-name leak Gargi Sharma
2017-02-21 19:45 ` Johan Hovold
2017-02-21 19:50 ` Johan Hovold
2017-02-22 10:15   ` [Outreachy kernel] " Gargi Sharma
2017-02-22 10:24     ` Julia Lawall
2017-02-22 10:37     ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.