Skip to content

Commit

Permalink
dpaa2-mac: bail if the dpmacs fwnode is not found
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Robert-Ionut Alexa authored and Jakub Kicinski committed Jan 7, 2022
1 parent 257367c commit 5b1e38c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand Down

0 comments on commit 5b1e38c

Please sign in to comment.