lkml.org 
[lkml]   [2021]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.19 25/55] net: bcmgenet: check return value after calling platform_get_resource()
    Date
    From: Yang Yingliang <yangyingliang@huawei.com>

    [ Upstream commit 74325bf0104573c6dfce42837139aeef3f34be76 ]

    It will cause null-ptr-deref if platform_get_resource() returns NULL,
    we need check the return value.

    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 ++++
    1 file changed, 4 insertions(+)

    diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
    index a5049d637791..494601c39b84 100644
    --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
    +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
    @@ -428,6 +428,10 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
    int id, ret;

    pres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    + if (!pres) {
    + dev_err(&pdev->dev, "Invalid resource\n");
    + return -EINVAL;
    + }
    memset(&res, 0, sizeof(res));
    memset(&ppd, 0, sizeof(ppd));

    --
    2.30.2
    \
     
     \ /
      Last update: 2021-07-06 14:11    [W:6.575 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site