[PATCH] selftests: media_device_test fix to close the fd before exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix it to close the fd before exit and in error legs.

Signed-off-by: Shuah Khan <shuahkh@xxxxxxxxxxxxxxx>
---
 tools/testing/selftests/media_tests/media_device_test.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/media_tests/media_device_test.c b/tools/testing/selftests/media_tests/media_device_test.c
index cbf53a0..dfb3ca6 100644
--- a/tools/testing/selftests/media_tests/media_device_test.c
+++ b/tools/testing/selftests/media_tests/media_device_test.c
@@ -84,12 +84,14 @@ int main(int argc, char **argv)
 
 	while (count < 100) {
 		ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi);
-		if (ret < 0)
+		if (ret < 0) {
 			printf("Media Device Info errno %s\n", strerror(errno));
-		else
-			printf("Media device model %s driver %s\n",
-				mdi.model, mdi.driver);
+			break;
+		}
+		printf("Media device model %s driver %s\n",
+			mdi.model, mdi.driver);
 		sleep(10);
 		count++;
 	}
+	close(fd);
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux