net/qede: fix resource leak
authorYong Wang <wang.yong19@zte.com.cn>
Wed, 30 Nov 2016 12:32:09 +0000 (07:32 -0500)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:39:28 +0000 (19:39 +0100)
Current code does not close 'fd' on function exit, leaking resources.

Fixes: 2ea6f76aff40 ("qede: add core driver")

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
Acked-by: Harish Patil <harish.patil@qlogic.com>
drivers/net/qede/qede_main.c

index ab22409..b666e1c 100644 (file)
@@ -137,6 +137,7 @@ static int qed_load_firmware_data(struct ecore_dev *edev)
 
        if (fstat(fd, &st) < 0) {
                DP_NOTICE(edev, false, "Can't stat firmware file\n");
+               close(fd);
                return -1;
        }
 
@@ -158,9 +159,11 @@ static int qed_load_firmware_data(struct ecore_dev *edev)
        if (edev->fw_len < 104) {
                DP_NOTICE(edev, false, "Invalid fw size: %" PRIu64 "\n",
                          edev->fw_len);
+               close(fd);
                return -EINVAL;
        }
 
+       close(fd);
        return 0;
 }
 #endif