lkml.org 
[lkml]   [2022]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 423/667] soc: bcm: Check for NULL return of devm_kzalloc()
    Date
    From: QintaoShen <unSimple1993@163.com>

    [ Upstream commit b4bd2aafacce48db26b0a213d849818d940556dd ]

    As the potential failure of allocation, devm_kzalloc() may return NULL. Then
    the 'pd->pmb' and the follow lines of code may bring null pointer dereference.

    Therefore, it is better to check the return value of devm_kzalloc() to avoid
    this confusion.

    Fixes: 8bcac4011ebe ("soc: bcm: add PM driver for Broadcom's PMB")
    Signed-off-by: QintaoShen <unSimple1993@163.com>
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/soc/bcm/bcm63xx/bcm-pmb.c | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/drivers/soc/bcm/bcm63xx/bcm-pmb.c b/drivers/soc/bcm/bcm63xx/bcm-pmb.c
    index 774465c119be..2ac20084e5a5 100644
    --- a/drivers/soc/bcm/bcm63xx/bcm-pmb.c
    +++ b/drivers/soc/bcm/bcm63xx/bcm-pmb.c
    @@ -314,6 +314,9 @@ static int bcm_pmb_probe(struct platform_device *pdev)
    for (e = table; e->name; e++) {
    struct bcm_pmb_pm_domain *pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);

    + if (!pd)
    + return -ENOMEM;
    +
    pd->pmb = pmb;
    pd->data = e;
    pd->genpd.name = e->name;
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-06-07 21:32    [W:2.857 / U:0.164 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site