lkml.org 
[lkml]   [2022]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.17 004/343] net: dsa: felix: fix possible NULL pointer dereference
    Date
    From: Zheng Yongjun <zhengyongjun3@huawei.com>

    [ Upstream commit 866b7a278cdb51eb158cd8513bc7438fc857804a ]

    As the possible failure of the allocation, kzalloc() may return NULL
    pointer.
    Therefore, it should be better to check the 'sgi' in order to prevent
    the dereference of NULL pointer.

    Fixes: 23ae3a7877718 ("net: dsa: felix: add stream gate settings for psfp").
    Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
    Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20220329090800.130106-1-zhengyongjun3@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++
    1 file changed, 4 insertions(+)

    diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
    index 33f0ceae381d..2875b5250856 100644
    --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
    +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
    @@ -1940,6 +1940,10 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
    case FLOW_ACTION_GATE:
    size = struct_size(sgi, entries, a->gate.num_entries);
    sgi = kzalloc(size, GFP_KERNEL);
    + if (!sgi) {
    + ret = -ENOMEM;
    + goto err;
    + }
    vsc9959_psfp_parse_gate(a, sgi);
    ret = vsc9959_psfp_sgi_table_add(ocelot, sgi);
    if (ret) {
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-04-12 10:23    [W:3.076 / U:0.240 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site