• David Rivshin's avatar
    drivers: net: cpsw: fix segfault in case of bad phy-handle · d733f754
    David Rivshin authored
    If an emac node has a phy-handle property that points to something
    which is not a phy, then a segmentation fault will occur when the
    interface is brought up. This is because while phy_connect() will
    return ERR_PTR() on failure, of_phy_connect() will return NULL.
    The common error check uses IS_ERR(), and so missed when
    of_phy_connect() fails. The NULL pointer is then dereferenced.
    
    Also, the common error message referenced slave->data->phy_id,
    which would be empty in the case of phy-handle. Instead, use the
    name of the device_node as a useful identifier. And in the phy_id
    case add the error code for completeness.
    
    Fixes: 9e42f715 ("drivers: net: cpsw: add phy-handle parsing")
    Signed-off-by: default avatarDavid Rivshin <drivshin@allworx.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d733f754
cpsw.c 71.1 KB