[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c182e228-28dc-aad7-afbb-073b2e6caa10@omp.ru>
Date: Thu, 8 Sep 2022 23:30:04 +0300
From: Sergey Shtylyov <s.shtylyov@....ru>
To: Jim Lin <jilin@...dia.com>, <balbi@...nel.org>,
<gregkh@...uxfoundation.org>
CC: <linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Aniruddha TVS Rao <anrao@...dia.com>
Subject: Re: [PATCH] usb: gadget: rndis: Avoid dereference before NULL check
On 9/8/22 8:56 PM, Jim Lin wrote:
> NULL check is performed after params->dev is dereferenced in
> dev_get_stats.
> Fixed by adding a NULL check before dereferencing params->dev and
> removing subsequent NULL checks for it.
You've beaten me to send such a patch... :-)
>
> Signed-off-by: Aniruddha TVS Rao <anrao@...dia.com>
> Signed-off-by: Jim Lin <jilin@...dia.com>
> ---
> drivers/usb/gadget/function/rndis.c | 37 ++++++++++++-----------------
> 1 file changed, 15 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c
> index 64de9f1b874c..d2f18f34c8e5 100644
> --- a/drivers/usb/gadget/function/rndis.c
> +++ b/drivers/usb/gadget/function/rndis.c
> @@ -198,6 +198,9 @@ static int gen_ndis_query_resp(struct rndis_params *params, u32 OID, u8 *buf,
> outbuf = (__le32 *)&resp[1];
> resp->InformationBufferOffset = cpu_to_le32(16);
>
> + if (!params->dev)
> + return -ENODEV;
> +
Hm, isn't this checked at the start of rndis_query_response(), this function's
only caller?
[...]
MBR, Sergey
Powered by blists - more mailing lists