[PATCH i-g-t 1/2] igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion

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

 



Long time ago, there was an issue with driver crashing due to lack of
error handling on struct file creation (gem_create()). We're unable to hit
this scenario, because dup() does not creat flip. Let's replace dup() with
open() and assert that error is returned on exhaustion.

Signed-off-by: Karol Krol <karol.krol@xxxxxxxxx>
---
 tests/gem_fd_exhaustion.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/gem_fd_exhaustion.c b/tests/gem_fd_exhaustion.c
index 0969f9c6..6750444e 100644
--- a/tests/gem_fd_exhaustion.c
+++ b/tests/gem_fd_exhaustion.c
@@ -65,7 +65,7 @@ igt_simple_main
 		igt_drop_root();
 
 		for (int i = 0; ; i++) {
-			int leak = dup(fd);
+			int leak = open("/dev/null", O_RDONLY);
 			uint32_t handle;
 
 			if (__gem_create(fd, 4096, &handle) == 0)
@@ -73,6 +73,8 @@ igt_simple_main
 
 			if (leak < 0) {
 				igt_info("fd exhaustion after %i rounds.\n", i);
+				igt_assert(__gem_create(fd, 4096,
+							&handle) == -ENFILE);
 				break;
 			}
 		}
-- 
2.14.3

--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux