Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6945585ybn; Mon, 30 Sep 2019 06:22:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH9UKNnDojgvkdGBS4w/uB/soBg77WkdKGcFp1t5W5wkkqANRTWkEU9QEUSrpkG3y4L/pe X-Received: by 2002:a17:906:5295:: with SMTP id c21mr10223673ejm.80.1569849739315; Mon, 30 Sep 2019 06:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569849739; cv=none; d=google.com; s=arc-20160816; b=QgnJBFH0pLf+dzyQ8SPJX4Tnh5h6rEijkSr+yxuzw/k62BUaImz3g8O+PtN92n9zfU RpugFDPpXLx/Hz8og1qym6MzJF3u4ib8xhtOH1mP8TjAU+Zqr99qfz/T3cJ1ZfuwGwnM 42KRbq9lnkbqbMLQr3aOC5mNITXgFS33K2tCgdpLyh5cJh2hmk3amonz59C3or6E1x/r yvkf+8O4iONDP6HOuzy8CLu3gx4ABkQCO9eDYKe+V6UsNWqkrsStp/yRQx0xg5mxXvI2 knJsphGhxaSIkp/vgcbShots76deYttN9Ze67xONAmIQaSz95SeqJIQgvR3A1WdLlDB8 r8fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=B5Mgx5TWuxEdNYpLT0IZgdQ+Kbjdwx5/ku1Xohv+9y8=; b=urS2uG/3utEdp3sHcftLUteyzD+JXXl1Aw2DxOem3nlFlR3G1Xeyo72JYshK771euY FuTp9W3zwzS2N4v6NrsKMMFsQgG8wVVUIxtC5uQHhmPui1D7LLLyH+NYaecutE030w2w 6yfHaaPR5P3rCusG2+faON3jrQkdWCGagmTT8pSfQ8M96Lmmpfs6gWz8/CPfxr0QWDFH v0AJlWbB6G7UumxERBXnl+j24zz8MKK6GegHljs+5JIEbWml//8Hi+nrUy8pzngyMzHD +vYNTKmBVVNtVdhP5gGKkbRtSvCSxQuCDNwWcQfgKV+DrY3XvwR7tuev7GzR1dMNH9lf lKjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17si6688923edv.76.2019.09.30.06.21.54; Mon, 30 Sep 2019 06:22:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731234AbfI3NSg convert rfc822-to-8bit (ORCPT + 99 others); Mon, 30 Sep 2019 09:18:36 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([146.101.78.151]:45193 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfI3NSg (ORCPT ); Mon, 30 Sep 2019 09:18:36 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-207-hnslXOvPO-C_5kCPTbZeHQ-1; Mon, 30 Sep 2019 14:18:32 +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; Mon, 30 Sep 2019 14:18:32 +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; Mon, 30 Sep 2019 14:18:32 +0100 From: David Laight To: 'Denis Efremov' , "devel@driverdev.osuosl.org" CC: "linux-kernel@vger.kernel.org" , "Greg Kroah-Hartman" , Hans de Goede , Bastien Nocera , Larry Finger , Jes Sorensen , "stable@vger.kernel.org" Subject: RE: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls Thread-Topic: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls Thread-Index: AQHVd36LU5ikVLKK6EuvH5wLNYQtMKdEMyLw Date: Mon, 30 Sep 2019 13:18:32 +0000 Message-ID: <37b195b700394e95aa8329afc9f60431@AcuMS.aculab.com> References: <20190930110141.29271-1-efremov@linux.com> In-Reply-To: <20190930110141.29271-1-efremov@linux.com> 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: hnslXOvPO-C_5kCPTbZeHQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Denis Efremov > Sent: 30 September 2019 12:02 > memcpy() in phy_ConfigBBWithParaFile() and PHY_ConfigRFWithParaFile() is > called with "src == NULL && len == 0". This is an undefined behavior. I'm pretty certain it is well defined (to do nothing). > Moreover this if pre-condition "pBufLen && (*pBufLen == 0) && !pBuf" > is constantly false because it is a nested if in the else brach, i.e., > "if (cond) { ... } else { if (cond) {...} }". This patch alters the > if condition to check "pBufLen && pBuf" pointers are not NULL. > ... > --- > Not tested. I don't have the hardware. The fix is based on my guess. > > drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c > index 6539bee9b5ba..0902dc3c1825 100644 > --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c > +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c > @@ -2320,7 +2320,7 @@ int phy_ConfigBBWithParaFile( > } > } > } else { > - if (pBufLen && (*pBufLen == 0) && !pBuf) { > + if (pBufLen && pBuf) { > memcpy(pHalData->para_file_buf, pBuf, *pBufLen); The existing code is clearly garbage. It only ever does memcpy(tgt, NULL, 0). Under the assumption that the code has been tested the copy clearly isn't needed at all and can be deleted completely! OTOH if the code hasn't been tested maybe the entire source file should be removed :-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)