Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1689598imw; Tue, 5 Jul 2022 13:49:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v9H33Zj6ZD2hc31bMRaJZwscEWptfGZK7PFTtDuDwY9SIESKG7jnEiLBeSa/8cdOdGiIBh X-Received: by 2002:a17:90a:72c9:b0:1ef:8927:6e42 with SMTP id l9-20020a17090a72c900b001ef89276e42mr14548238pjk.148.1657054165368; Tue, 05 Jul 2022 13:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657054165; cv=none; d=google.com; s=arc-20160816; b=HKTJQkenzd3NismXp2kjNpe2uDiBCRivi1kyoSXsfaVe538u2VKUzIRQWu48nO2AvL Pa3aimi2e3AJuslaxQTvODStnP/tIzXTwNSUB0RX/QndvAYJ5bfuSwz1MVJuEzO1HRsV iVE3FyS39dIwwIFdK1iz9IVvsfc0pXEDyyGzwamfQ2xdqAS1i1Fejya45OW2Y591un01 FNzdQJEj1iwCVf+z5O0ujQFLBx30vL4aSTaQQUwyUPHcTi17xhiCbgfjH94ekem2LQIU ZcTWEX7KyYk+IITIDal06pQPamssK4dEtjpXjm9FWnceShFdZ/xXYX8JKJNg0UkeR9Lz RHlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FIdx2iCQWmh232D6cr12WoB04qTGDNIR1Qt3g0O4G8o=; b=TWvDnGcstN1K2S44wjY7nhv9JQWbOPlVn24CVc0ZlRuz1qFzItIWmzSfHMh6Rp2h0b wKbOXmg6v3GiUy7tvGnmLWDc6gfmIfHfpfGgDVTVPDq+twu286lspliBbHNFM3ZgbUf0 EsYMQYV+1fZDDQI1GYYE2cM2DDmAq52lQDDN/jX/G7GKW4i05UjHBDKZxyBEN2Rft+lK SPtBBsEp24Qu5kVeUqrrtimn+tq2/gM6kcB55p3N6snQE3iGpttF2UDpKt4tAAwYYYPt TOEvON4S8N2FAV36QJX/PQfE+qd1sbSzEOD7OnEoyIX3sBbPWK/8tCcU2i+Ng8kWIRQ4 jusQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020aa7888f000000b005251ab96060si49607408pfe.247.2022.07.05.13.49.13; Tue, 05 Jul 2022 13:49:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231196AbiGEUgI (ORCPT + 99 others); Tue, 5 Jul 2022 16:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiGEUgH (ORCPT ); Tue, 5 Jul 2022 16:36:07 -0400 Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B23CD192B4; Tue, 5 Jul 2022 13:36:05 -0700 (PDT) Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 6867C1C0001; Tue, 5 Jul 2022 22:36:02 +0200 (CEST) Date: Tue, 5 Jul 2022 22:36:02 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 4.9 05/29] usbnet: make sure no NULL pointer is passed through Message-ID: <20220705203601.GA3184@amd> References: <20220705115605.742248854@linuxfoundation.org> <20220705115605.903898317@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline In-Reply-To: <20220705115605.903898317@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NEUTRAL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Oliver Neukum >=20 > commit 6c22fce07c97f765af1808ec3be007847e0b47d1 upstream. >=20 > Coverity reports: >=20 > ** CID 751368: Null pointer dereferences (FORWARD_NULL) > /drivers/net/usb/usbnet.c: 1925 in __usbnet_read_cmd() >=20 > _________________________________________________________________________= _______________________________ 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 =09 > --- a/drivers/net/usb/usbnet.c > +++ b/drivers/net/usb/usbnet.c > @@ -1960,8 +1960,13 @@ static int __usbnet_read_cmd(struct usbn > err =3D usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), > cmd, reqtype, value, index, buf, size, > USB_CTRL_GET_TIMEOUT); > - if (err > 0 && err <=3D size) > - memcpy(data, buf, err); > + if (err > 0 && err <=3D 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 =3D kmemdup(data, size, GFP_KERNEL); > if (!buf) > goto out; > - } > + } else { > + if (size) { > + WARN_ON_ONCE(1); > + err =3D -EINVAL; > + goto out; > + } > + } > =20 > err =3D usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), > cmd, reqtype, value, index, buf, size, >=20 --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --C7zPtVaVf+AK4Oqc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmLEoLEACgkQMOfwapXb+vIZqwCfX0mpHAw+0dynaI7ZHL1Nxgdg fK8AnidRkrzg/vEgwd4aM0QcENMUoVx6 =arxU -----END PGP SIGNATURE----- --C7zPtVaVf+AK4Oqc--