From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAE85C352AA for ; Tue, 1 Oct 2019 16:00:38 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB7512070B for ; Tue, 1 Oct 2019 16:00:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB7512070B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 829632051B; Tue, 1 Oct 2019 16:00:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s5La4qTWG7Oi; Tue, 1 Oct 2019 16:00:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id DF7792048F; Tue, 1 Oct 2019 16:00:33 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 7EE721BF981 for ; Tue, 1 Oct 2019 16:00:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 68E381FD42 for ; Tue, 1 Oct 2019 16:00:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jFLWH01-yy8Q for ; Tue, 1 Oct 2019 16:00:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [207.82.80.151]) by silver.osuosl.org (Postfix) with ESMTPS id 05AAC1FEE0 for ; Tue, 1 Oct 2019 16:00:29 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-164--oUOnduMO7u6T_CwoD2SuA-1; Tue, 01 Oct 2019 17:00:21 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 1 Oct 2019 17:00:21 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Tue, 1 Oct 2019 17:00:21 +0100 From: David Laight To: "'efremov@linux.com'" , 'Dan Carpenter' Subject: RE: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls Thread-Topic: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls Thread-Index: AQHVd36LU5ikVLKK6EuvH5wLNYQtMKdEMyLwgAGeKE+AAAh2kP///AWAgAAc6lA= Date: Tue, 1 Oct 2019 16:00:20 +0000 Message-ID: <35c2d89987854fb8a42f04dc28ad4bc9@AcuMS.aculab.com> References: <20190930110141.29271-1-efremov@linux.com> <37b195b700394e95aa8329afc9f60431@AcuMS.aculab.com> <20191001135649.GH22609@kadam> <8d2e8196cae74ec4ae20e9c23e898207@AcuMS.aculab.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: -oUOnduMO7u6T_CwoD2SuA-1 X-Mimecast-Spam-Score: 0 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "devel@driverdev.osuosl.org" , Jes Sorensen , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Hans de Goede , Bastien Nocera , Dmitry Vyukov , Larry Finger Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" From: Denis Efremov > Sent: 01 October 2019 16:13 ... > Just found an official documentation to this issue: > https://gcc.gnu.org/gcc-4.9/porting_to.html > "Null pointer checks may be optimized away more aggressively > ... > The pointers passed to memmove (and similar functions in ) must be non-null > even when nbytes==0, so GCC can use that information to remove the check after the > memmove call. Calling copy(p, NULL, 0) can therefore deference a null pointer and crash." Right, so just don't code a NULL pointer test after a memcpy() call. There is no need to avoid the call itself. > But again, I would say that the bug in this code is because the if condition was copy-pasted > and it should be inverted. Oh, the code is question is just stupidly bad. It seemed to do: if (a) x; else if (!a) y; else error ("all borked") If the whole driver is written like that it needs fixing before anyone takes a serious look at it. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel