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

Karol Krol karol.krol at intel.com
Mon Mar 5 17:36:41 UTC 2018


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.

v2: Pass if gem_create fails on exhaustion, no matter the errno.

Signed-off-by: Karol Krol <karol.krol at intel.com>
---
I'm still working on getting rid of e-mail footer. I'll appreciate reviews.
---
 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..fdcb7f36 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) < 0);
 				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.



More information about the igt-dev mailing list