Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agra...@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c            |  6 ++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |  6 ++----
 drivers/bus/ifpga/ifpga_bus.c            | 12 ++++--------
 drivers/bus/pci/pci_params.c             |  3 +--
 drivers/bus/pci/windows/pci.c            |  3 +--
 drivers/bus/pci/windows/pci_netuio.c     |  3 +--
 6 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 356253f6b412..e9edc27e0ab0 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -221,13 +221,11 @@ scan_one_fslmc_device(char *dev_name)
        insert_in_device_list(dev);
 
        /* Don't need the duplicated device filesystem entry anymore */
-       if (dup_dev_name)
-               free(dup_dev_name);
+       free(dup_dev_name);
 
        return 0;
 cleanup:
-       if (dup_dev_name)
-               free(dup_dev_name);
+       free(dup_dev_name);
        if (dev) {
                rte_intr_instance_free(dev->intr_handle);
                free(dev);
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c 
b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 52605ea2c32c..943fadee4816 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -149,8 +149,7 @@ dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, 
int cpu_id)
        if (!token) {
                DPAA2_BUS_WARN("Failed to get interrupt id for dpio.%d",
                               dpio_id);
-               if (temp)
-                       free(temp);
+               free(temp);
                fclose(file);
                return;
        }
@@ -574,8 +573,7 @@ dpaa2_free_dq_storage(struct queue_storage_info_t 
*q_storage)
        int i = 0;
 
        for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
-               if (q_storage->dq_storage[i])
-                       rte_free(q_storage->dq_storage[i]);
+               rte_free(q_storage->dq_storage[i]);
        }
 }
 
diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index c5c8bbd57219..e005f2cb70b3 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -191,10 +191,8 @@ ifpga_scan_one(struct rte_rawdev *rawdev,
        return afu_dev;
 
 end:
-       if (kvlist)
-               rte_kvargs_free(kvlist);
-       if (path)
-               free(path);
+       rte_kvargs_free(kvlist);
+       free(path);
        if (afu_dev) {
                rte_intr_instance_free(afu_dev->intr_handle);
                free(afu_dev);
@@ -254,10 +252,8 @@ ifpga_scan(void)
        }
 
 end:
-       if (kvlist)
-               rte_kvargs_free(kvlist);
-       if (name)
-               free(name);
+       rte_kvargs_free(kvlist);
+       free(name);
 
        return 0;
 }
diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index 60b424b8297e..61a868707f16 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -117,8 +117,7 @@ rte_pci_devargs_parse(struct rte_devargs *da)
        rte_pci_device_name(&addr, da->name, sizeof(da->name));
 
 out:
-       if (kvargs != NULL)
-               rte_kvargs_free(kvargs);
+       rte_kvargs_free(kvargs);
        if (ret != 0)
                rte_errno = -ret;
        return ret;
diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index 39ba31be7d38..7bf091158ba2 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -418,8 +418,7 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA 
device_info_data)
 
        return 0;
 end:
-       if (dev)
-               free(dev);
+       free(dev);
        return ret;
 }
 
diff --git a/drivers/bus/pci/windows/pci_netuio.c 
b/drivers/bus/pci/windows/pci_netuio.c
index a0b175a8fca0..5460399eea5f 100644
--- a/drivers/bus/pci/windows/pci_netuio.c
+++ b/drivers/bus/pci/windows/pci_netuio.c
@@ -180,8 +180,7 @@ get_netuio_device_info(HDEVINFO dev_info, PSP_DEVINFO_DATA 
dev_info_data,
                        CloseHandle(netuio);
        }
 
-       if (dev_ifx_detail)
-               free(dev_ifx_detail);
+       free(dev_ifx_detail);
 
        if (di_set != INVALID_HANDLE_VALUE)
                SetupDiDestroyDeviceInfoList(di_set);
-- 
2.34.1

Reply via email to