driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: hal: Fix memcpy calls
@ 2019-09-30 11:01 Denis Efremov
  2019-09-30 13:18 ` David Laight
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Denis Efremov @ 2019-09-30 11:01 UTC (permalink / raw)
  To: devel
  Cc: Jes Sorensen, Greg Kroah-Hartman, linux-kernel, Denis Efremov,
	Hans de Goede, stable, Bastien Nocera, Larry Finger

memcpy() in phy_ConfigBBWithParaFile() and PHY_ConfigRFWithParaFile() is
called with "src == NULL && len == 0". This is an undefined behavior.
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.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bastien Nocera <hadess@hadess.net>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Jes Sorensen <jes.sorensen@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Denis Efremov <efremov@linux.com>
---
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);
 			rtStatus = _SUCCESS;
 		} else
@@ -2752,7 +2752,7 @@ int PHY_ConfigRFWithParaFile(
 			}
 		}
 	} else {
-		if (pBufLen && (*pBufLen == 0) && !pBuf) {
+		if (pBufLen && pBuf) {
 			memcpy(pHalData->para_file_buf, pBuf, *pBufLen);
 			rtStatus = _SUCCESS;
 		} else
-- 
2.21.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-10-09 14:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 11:01 [PATCH] staging: rtl8723bs: hal: Fix memcpy calls Denis Efremov
2019-09-30 13:18 ` David Laight
2019-09-30 14:25   ` Denis Efremov
2019-10-01 13:56     ` Dan Carpenter
2019-10-01 14:36       ` David Laight
2019-10-01 15:13         ` Denis Efremov
2019-10-01 16:00           ` David Laight
2019-10-01 18:58           ` Dan Carpenter
2019-10-01 20:15             ` Denis Efremov
2019-10-09 14:38             ` Dan Carpenter
2019-09-30 15:40   ` Denis Efremov
2019-09-30 13:39 ` Sasha Levin
2019-10-09  9:35 ` Hans de Goede
2019-10-09 10:43   ` Denis Efremov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).