lkml.org 
[lkml]   [2019]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.1 171/405] staging: vc04_services: handle kzalloc failure
    Date
    [ Upstream commit a5112277872a56017b777770e2fd4324d4a6c866 ]

    The kzalloc here was being used without checking the return - if the
    kzalloc fails return VCHIQ_ERROR. The call-site of
    vchiq_platform_init_state() vchiq_init_state() was not responding
    to an allocation failure so checks for != VCHIQ_SUCCESS
    and pass VCHIQ_ERROR up to vchiq_platform_init() which then
    will fail with -EINVAL.

    Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
    Reported-by: kbuild test robot <lkp@intel.com>
    Acked-By: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 3 +++
    drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 ++
    2 files changed, 5 insertions(+)

    diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
    index dd4898861b833..eb1e5dcb0d529 100644
    --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
    +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
    @@ -209,6 +209,9 @@ vchiq_platform_init_state(struct vchiq_state *state)
    struct vchiq_2835_state *platform_state;

    state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
    + if (!state->platform_state)
    + return VCHIQ_ERROR;
    +
    platform_state = (struct vchiq_2835_state *)state->platform_state;

    platform_state->inited = 1;
    diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
    index 53f5a1cb4636e..819813e742d8a 100644
    --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
    +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
    @@ -2239,6 +2239,8 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero)
    local->debug[DEBUG_ENTRIES] = DEBUG_MAX;

    status = vchiq_platform_init_state(state);
    + if (status != VCHIQ_SUCCESS)
    + return VCHIQ_ERROR;

    /*
    bring up slot handler thread
    --
    2.20.1


    \
     
     \ /
      Last update: 2019-05-30 06:52    [W:4.135 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site