lkml.org 
[lkml]   [2022]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] usb: gadget: rndis: Avoid dereference before NULL check
From
Date
Hello!

On 9/9/22 8:38 AM, Greg KH wrote:

>> NULL check is performed after params->dev is dereferenced in
>> dev_get_stats.
>
> I do not understand this statement.
>
>> Fixed by adding a NULL check before dereferencing params->dev and
>> removing subsequent NULL checks for it.
>>
>> Signed-off-by: Aniruddha TVS Rao <anrao@nvidia.com>
>> Signed-off-by: Jim Lin <jilin@nvidia.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;
>> +
>
> As Sergey points out, this check is useless and the ones below should
> also be removed.

Would you accept this patch modulo the above check then? If not,
I'll just resolve the corresponding SVACE checker as "won't fix" here. :-)

> But, why make this check at all, how did you trigger a problem with the
> current code?

There's no problem, just the redundant NULL checks...

> Are you using this driver? If so, why? It is totally broken (as per
> the specification) and we really really need to just delete it from the
> tree to prevent anyone else from ever using it.

Well, delete it then... :-)

> thanks,
>
> greg k-h

MBR, Sergey

\
 
 \ /
  Last update: 2022-09-22 23:00    [W:0.058 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site