Skip to contentSkip to conversation

Staging: iio: Documentation: Fix resource leak in function dump_channels

PATCH In review Darshana Padmadas 2 participants 2 messages Mar 19, 2015 – Mar 20, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: iio: Documentation: Fix resource leak in function dump_channels

This patch fixes the following error reported by cppcheck tool:
[drivers/staging/iio/Documentation/lsiio.c:59]: (error) Resource leak: dp

The closedir function closes the file descriptor dp which was previously opened by calling opendir and eliminated the cppcheck error.

---
 drivers/staging/iio/Documentation/lsiio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/Documentation/lsiio.c +1 -0
index 98a0de0..7935ffc 100644
@@ -55,6 +55,7 @@ static int dump_channels(const char *dev_dir_name)
 		    check_postfix(ent->d_name, "_raw")) {
 			printf("   %-10s\n", ent->d_name);
 		}
+	closedir(dp);
 
 	return 0;
 }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 6 lines · Darshana Padmadas

This patch fixes the following error reported by cppcheck tool:
[drivers/staging/iio/Documentation/lsiio.c:59]: (error) Resource leak: dp

The closedir function closes the file descriptor dp which was previously opened by calling opendir and eliminated the cppcheck error.

This is a nice fix!

lsiio was recently moved from staging to tools/iio. I think it's better to rebase your patch on top of Jonathan's iio tree [1] (togreg branch).

.. and have this patch merged via linux-iio.

Daniel.

[1] https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/