From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D417B23A0 for ; Mon, 6 Jun 2022 05:48:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 414E3C341CA; Mon, 6 Jun 2022 05:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654494532; bh=Dvz2wGZ0SUD3hGXKJv7F+hdhAS0fs0Hbg/vlNnnbu04=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m+z3WMkQml0kACZBfXKVHiwEluGjiPMXHHkh1Xsjlju7rllZb+S/QgR2iofAO3pkk FZ8Pw6HwSSXZsb0Y5vzhy27dNt8fR2BWo4+mMVsZat2i3t2QNjsk5uDCxyu2vzsvL0 mCf/j5jWCzNrqIRGwJ3k3c8HnXP9ta2KQycdobsU= Date: Mon, 6 Jun 2022 07:48:49 +0200 From: Greg KH To: Pavel Skripkin Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, straube.linux@gmail.com, dan.carpenter@oracle.com, fmdefrancesco@gmail.com, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH v2 2/4] staging: r8188eu: add error handling of rtw_read16 Message-ID: References: Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, May 20, 2022 at 12:09:55AM +0300, Pavel Skripkin wrote: > rtw_read16() reads data from device via USB API which may fail. In case > of any failure previous code returned stack data to callers, which is > wrong. > > Fix it by changing rtw_read16() prototype and prevent caller from > touching random stack data > > Signed-off-by: Pavel Skripkin > --- > > Changes since v1: > - Fixed style issue > > --- > .../staging/r8188eu/hal/rtl8188e_hal_init.c | 21 ++++++++++++--- > drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 8 ++++-- > drivers/staging/r8188eu/hal/usb_halinit.c | 27 ++++++++++++++++--- > drivers/staging/r8188eu/hal/usb_ops_linux.c | 13 ++++++--- > drivers/staging/r8188eu/include/rtw_io.h | 2 +- > drivers/staging/r8188eu/os_dep/ioctl_linux.c | 9 ++++--- > drivers/staging/r8188eu/os_dep/os_intfs.c | 6 ++++- > 7 files changed, 67 insertions(+), 19 deletions(-) > > diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c > index e67ecbd1ba79..6662ebc30f7b 100644 > --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c > +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c > @@ -249,11 +249,14 @@ static void efuse_read_phymap_from_txpktbuf( > hi32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H)); > > if (i == 0) { > + u16 reg; > + > /* Although lenc is only used in a debug statement, > * do not remove it as the rtw_read16() call consumes > * 2 bytes from the EEPROM source. > */ > - rtw_read16(adapter, REG_PKTBUF_DBG_DATA_L); > + res = rtw_read16(adapter, REG_PKTBUF_DBG_DATA_L, ®); > + (void)res; Same here, that line isn't ok. thanks, greg k-h