]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dpaa2-mac: bail if the dpmacs fwnode is not found
authorRobert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Thu, 6 Jan 2022 13:59:03 +0000 (15:59 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 7 Jan 2022 03:49:10 +0000 (19:49 -0800)
The parent pointer node handler must be declared with a NULL
initializer. Before using it, a check must be performed to make
sure that a valid address has been assigned to it.

Signed-off-by: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c

index 7f509f427e3d6d262cc6c7ac1bd610fcf8f7d852..e80376c6e55e38c773e8e412cf4e568fb350abbb 100644 (file)
@@ -41,7 +41,7 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
 static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
                                                u16 dpmac_id)
 {
-       struct fwnode_handle *fwnode, *parent, *child  = NULL;
+       struct fwnode_handle *fwnode, *parent = NULL, *child  = NULL;
        struct device_node *dpmacs = NULL;
        int err;
        u32 id;
@@ -56,6 +56,9 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
                parent = fwnode;
        }
 
+       if (!parent)
+               return NULL;
+
        fwnode_for_each_child_node(parent, child) {
                err = -EINVAL;
                if (is_acpi_device_node(child))