nvc0: Fix fd leak in nvc0_create_decoder
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Sun, 24 Mar 2013 13:37:41 +0000 (14:37 +0100)
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>
Tue, 2 Apr 2013 08:25:26 +0000 (10:25 +0200)
NOTE: This is a candidate for the 9.0 and 9.1 branches.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
src/gallium/drivers/nvc0/nvc0_video.c

index cdb80dba064f7eed2b10bc2eda9187786b660fa6..b185ded09f0628f52bfb9d83d02bc6563a5b3db2 100644 (file)
@@ -356,19 +356,19 @@ nvc0_create_decoder(struct pipe_context *context,
          goto fw_fail;
       }
       r = read(fd, dec->fw_bo->map, 0x4000);
+      close(fd);
+
       if (r < 0) {
          fprintf(stderr, "reading firmware file %s failed: %m\n", path);
          goto fw_fail;
       }
 
       if (r == 0x4000) {
-         close(fd);
          fprintf(stderr, "firmware file %s too large!\n", path);
          goto fw_fail;
       }
 
       if (r & 0xff) {
-         close(fd);
          fprintf(stderr, "firmware file %s wrong size!\n", path);
          goto fw_fail;
       }