All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: loop variable to loop index
@ 2017-02-21 16:59 Gargi Sharma
  2017-02-21 17:31 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Gargi Sharma @ 2017-02-21 16:59 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, johan, elder, Gargi Sharma

Change array index from the loop bound variable to loop index.
Once all the loopback devices have been found, free the pointer
array containing the dirent structures. 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>
---
 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] 5+ messages in thread

end of thread, other threads:[~2017-02-21 19:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 16:59 [PATCH] staging: greybus: loop variable to loop index Gargi Sharma
2017-02-21 17:31 ` [Outreachy kernel] " Julia Lawall
2017-02-21 18:19   ` Johan Hovold
2017-02-21 19:50     ` Julia Lawall
2017-02-21 19:54       ` 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.