lkml.org 
[lkml]   [2020]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 036/136] staging: greybus: fix a missing-check bug in gb_lights_light_config()
    Date
    From: Chen Zhou <chenzhou10@huawei.com>

    [ Upstream commit 9bb086e5ba9495ac150fbbcc5c8c2bccc06261dd ]

    In gb_lights_light_config(), 'light->name' is allocated by kstrndup().
    It returns NULL when fails, add check for it.

    Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
    Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
    Link: https://lore.kernel.org/r/20200401030017.100274-1-chenzhou10@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/staging/greybus/light.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
    index 4e7575147775d..9fab0e2751aa6 100644
    --- a/drivers/staging/greybus/light.c
    +++ b/drivers/staging/greybus/light.c
    @@ -1033,7 +1033,8 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)

    light->channels_count = conf.channel_count;
    light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
    -
    + if (!light->name)
    + return -ENOMEM;
    light->channels = kcalloc(light->channels_count,
    sizeof(struct gb_channel), GFP_KERNEL);
    if (!light->channels)
    --
    2.25.1


    \
     
     \ /
      Last update: 2020-06-23 22:54    [W:4.157 / U:0.228 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site