[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57793438545e41cc85d00beab7505143@AcuMS.aculab.com>
Date: Wed, 20 Mar 2019 10:57:54 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Aditya Pakki' <pakki001@....edu>
CC: "kjlu@....edu" <kjlu@....edu>,
Andreas Noever <andreas.noever@...il.com>,
Michael Jamet <michael.jamet@...el.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Yehezkel Bernat <YehezkelShB@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <jakub.kicinski@...ronome.com>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"xdp-newbies@...r.kernel.org" <xdp-newbies@...r.kernel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>
Subject: RE: [PATCH] thunderbolt: xdomain: Fix to check return value of
kmemdup
From: Aditya Pakki
> Sent: 18 March 2019 22:55
>
> kmemdup can fail and return a NULL pointer. The patch modifies the
> signature of tb_xdp_schedule_request and passes the failure error upstream.
>
> Signed-off-by: Aditya Pakki <pakki001@....edu>
> ---
> drivers/thunderbolt/xdomain.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index e27dd8beb94b..b0e9cc30d708 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -526,7 +526,7 @@ static void tb_xdp_handle_request(struct work_struct *work)
> kfree(xw);
> }
>
> -static void
> +static bool
> tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr,
> size_t size)
> {
> @@ -534,13 +534,16 @@ tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr,
>
> xw = kmalloc(sizeof(*xw), GFP_KERNEL);
> if (!xw)
> - return;
> + return false;
>
> INIT_WORK(&xw->work, tb_xdp_handle_request);
> xw->pkg = kmemdup(hdr, size, GFP_KERNEL);
> + if (!xw->pkg)
> + return false;
You're leaking 'xw' here.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists