lkml.org 
[lkml]   [2021]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 15/88] nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done
    Date
    From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

    commit 4cd8371a234d051f9c9557fcbb1f8c523b1c0d10 upstream.

    The done() netlink callback nfc_genl_dump_ses_done() should check if
    received argument is non-NULL, because its allocation could fail earlier
    in dumpit() (nfc_genl_dump_ses()).

    Fixes: ac22ac466a65 ("NFC: Add a GET_SE netlink API")
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Link: https://lore.kernel.org/r/20211209081307.57337-1-krzysztof.kozlowski@canonical.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/nfc/netlink.c | 6 ++++--
    1 file changed, 4 insertions(+), 2 deletions(-)

    --- a/net/nfc/netlink.c
    +++ b/net/nfc/netlink.c
    @@ -1400,8 +1400,10 @@ static int nfc_genl_dump_ses_done(struct
    {
    struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];

    - nfc_device_iter_exit(iter);
    - kfree(iter);
    + if (iter) {
    + nfc_device_iter_exit(iter);
    + kfree(iter);
    + }

    return 0;
    }

    \
     
     \ /
      Last update: 2021-12-13 10:59    [W:2.220 / U:0.572 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site