lkml.org 
[lkml]   [2022]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.9 05/29] usbnet: make sure no NULL pointer is passed through
Hi!

> From: Oliver Neukum <oneukum@suse.com>
>
> commit 6c22fce07c97f765af1808ec3be007847e0b47d1 upstream.
>
> Coverity reports:
>
> ** CID 751368: Null pointer dereferences (FORWARD_NULL)
> /drivers/net/usb/usbnet.c: 1925 in __usbnet_read_cmd()
>
> ________________________________________________________________________________________________________

There's something wrong here. Changelog is cut, so signed-offs are
missing. It is wrong in git, too.

There's something wrong with the whitespace in the patch (indentation
by 4 spaces instead of tab), too.

Best regards,
Pavel

> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1960,8 +1960,13 @@ static int __usbnet_read_cmd(struct usbn
> err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> cmd, reqtype, value, index, buf, size,
> USB_CTRL_GET_TIMEOUT);
> - if (err > 0 && err <= size)
> - memcpy(data, buf, err);
> + if (err > 0 && err <= size) {
> + if (data)
> + memcpy(data, buf, err);
> + else
> + netdev_dbg(dev->net,
> + "Huh? Data requested but thrown away.\n");
> + }
> kfree(buf);
> out:
> return err;
> @@ -1982,7 +1987,13 @@ static int __usbnet_write_cmd(struct usb
> buf = kmemdup(data, size, GFP_KERNEL);
> if (!buf)
> goto out;
> - }
> + } else {
> + if (size) {
> + WARN_ON_ONCE(1);
> + err = -EINVAL;
> + goto out;
> + }
> + }
>
> err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
> cmd, reqtype, value, index, buf, size,
>

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-07-05 22:36    [W:2.107 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site