Merge branch 'upstream-16.11-stable' into 16.11.x
[deb_dpdk.git] / drivers / net / qede / qede_main.c
index ab22409..60e24a7 100644 (file)
@@ -9,6 +9,7 @@
 #include <limits.h>
 #include <time.h>
 #include <rte_alarm.h>
+#include <rte_string_fns.h>
 
 #include "qede_ethdev.h"
 
@@ -137,6 +138,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 +160,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
@@ -299,9 +303,8 @@ static int qed_slowpath_start(struct ecore_dev *edev,
                drv_version.version = (params->drv_major << 24) |
                    (params->drv_minor << 16) |
                    (params->drv_rev << 8) | (params->drv_eng);
-               /* TBD: strlcpy() */
-               strncpy((char *)drv_version.name, (const char *)params->name,
-                       MCP_DRV_VER_STR_SIZE - 4);
+               strlcpy((char *)drv_version.name, (const char *)params->name,
+                       sizeof(drv_version.name));
                rc = ecore_mcp_send_drv_version(hwfn, hwfn->p_main_ptt,
                                                &drv_version);
                if (rc) {
@@ -342,11 +345,12 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
        rte_memcpy(&dev_info->hw_mac, &edev->hwfns[0].hw_info.hw_mac_addr,
               ETHER_ADDR_LEN);
 
+       dev_info->fw_major = FW_MAJOR_VERSION;
+       dev_info->fw_minor = FW_MINOR_VERSION;
+       dev_info->fw_rev = FW_REVISION_VERSION;
+       dev_info->fw_eng = FW_ENGINEERING_VERSION;
+
        if (IS_PF(edev)) {
-               dev_info->fw_major = FW_MAJOR_VERSION;
-               dev_info->fw_minor = FW_MINOR_VERSION;
-               dev_info->fw_rev = FW_REVISION_VERSION;
-               dev_info->fw_eng = FW_ENGINEERING_VERSION;
                dev_info->mf_mode = edev->mf_mode;
                dev_info->tx_switching = false;
        } else {