lkml.org 
[lkml]   [2019]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.20 084/304] staging: pi433: fix potential null dereference
    Date
    From: Michael Straube <straube.linux@gmail.com>

    [ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ]

    Add a test for successful call to cdev_alloc() to avoid
    potential null dereference. Issue reported by smatch.

    Signed-off-by: Michael Straube <straube.linux@gmail.com>
    Fixes: 874bcba65f9a ("staging: pi433: New driver")
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/staging/pi433/pi433_if.c | 4 ++++
    1 file changed, 4 insertions(+)

    diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
    index c85a805a1243..a497ec197872 100644
    --- a/drivers/staging/pi433/pi433_if.c
    +++ b/drivers/staging/pi433/pi433_if.c
    @@ -1255,6 +1255,10 @@ static int pi433_probe(struct spi_device *spi)

    /* create cdev */
    device->cdev = cdev_alloc();
    + if (!device->cdev) {
    + dev_dbg(device->dev, "allocation of cdev failed");
    + goto cdev_failed;
    + }
    device->cdev->owner = THIS_MODULE;
    cdev_init(device->cdev, &pi433_fops);
    retval = cdev_add(device->cdev, device->devt, 1);
    --
    2.19.1
    \
     
     \ /
      Last update: 2019-01-28 18:46    [W:4.036 / U:0.132 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site