lkml.org 
[lkml]   [2021]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 123/244] usb: gadget: r8a66597: Add missing null check on return from platform_get_resource
    Date
    From: Colin Ian King <colin.king@canonical.com>

    [ Upstream commit 9c2076090c2815fe7c49676df68dde7e60a9b9fc ]

    The call to platform_get_resource can potentially return a NULL pointer
    on failure, so add this check and return -EINVAL if it fails.

    Fixes: c41442474a26 ("usb: gadget: R8A66597 peripheral controller support.")
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Addresses-Coverity: ("Dereference null return")
    Link: https://lore.kernel.org/r/20210406184510.433497-1-colin.king@canonical.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/usb/gadget/udc/r8a66597-udc.c | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
    index 11e25a3f4f1f..a766476fd742 100644
    --- a/drivers/usb/gadget/udc/r8a66597-udc.c
    +++ b/drivers/usb/gadget/udc/r8a66597-udc.c
    @@ -1852,6 +1852,8 @@ static int r8a66597_probe(struct platform_device *pdev)
    return PTR_ERR(reg);

    ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
    + if (!ires)
    + return -EINVAL;
    irq = ires->start;
    irq_trigger = ires->flags & IRQF_TRIGGER_MASK;

    --
    2.30.2


    \
     
     \ /
      Last update: 2021-05-12 17:11    [W:2.105 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site