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=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 87F0DC32792 for ; Mon, 30 Sep 2019 11:02:31 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 6140521855 for ; Mon, 30 Sep 2019 11:02:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6140521855 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3248986225; Mon, 30 Sep 2019 11:02:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FIfPzU3IS1Mw; Mon, 30 Sep 2019 11:02:27 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 8654485B95; Mon, 30 Sep 2019 11:02:27 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id EFACF1BF568 for ; Mon, 30 Sep 2019 11:02:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id ECCA92045D for ; Mon, 30 Sep 2019 11:02:25 +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 iZs1ms5dSzgs for ; Mon, 30 Sep 2019 11:02:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by silver.osuosl.org (Postfix) with ESMTPS id EFB6D20392 for ; Mon, 30 Sep 2019 11:02:21 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id p7so12884114wmp.4 for ; Mon, 30 Sep 2019 04:02:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ms5iPF2H4/EUN9qkeORDrpoKQjqFYv3fNdSR7vI74Ys=; b=GDxZg1jp4K+sVWmrOzyKejv68FykkBgTkhK4BE35YNOVCNKjZh4rSU/HUtia+7E0yY tEuT0fIdpR/86vTT6vyC1am760H/++ATWNtMzPX0Byk2LHyE3OF1BB0wp6XJQftLwqQY s8+2HvVwDp6lSaienvdpEbSTivBNQqLx7dQKndPdIbvC1iXpRNsTAHhz/z84Ip585W6F 5LUuQQts9BrdiZSz6ZrzUG51Bx7SF9vRSyOYjRV0lTznK6u/ETjXZ0D9vua4KO9umxj7 KTM1CSx/oNa2EKGN72haQwtzcO6ZTPpNQS5pnstEUxox5uU86mCgPSibSc3WtKBK9kb2 aJKA== X-Gm-Message-State: APjAAAXieH1/ajWcFjY01FuXW8rWuB1mhblkL3D2fgbxT5Ogz0yILYtV UGnIIfyITK7kytjWHNy3Q3UqDA8y X-Google-Smtp-Source: APXvYqy6G2bUP18h/dG1Ymznd8phlt997hcwRCX+r1Htrq6oj5itwm6aXYaENnbK/mISBPIjuISu7A== X-Received: by 2002:a7b:c088:: with SMTP id r8mr17824239wmh.44.1569841340181; Mon, 30 Sep 2019 04:02:20 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id j26sm23653452wrd.2.2019.09.30.04.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 04:02:19 -0700 (PDT) From: Denis Efremov To: devel@driverdev.osuosl.org Subject: [PATCH] staging: rtl8723bs: hal: Fix memcpy calls Date: Mon, 30 Sep 2019 14:01:41 +0300 Message-Id: <20190930110141.29271-1-efremov@linux.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.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: Jes Sorensen , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Denis Efremov , Hans de Goede , stable@vger.kernel.org, Bastien Nocera , Larry Finger Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" 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 Cc: Hans de Goede Cc: Bastien Nocera Cc: Larry Finger Cc: Jes Sorensen Cc: stable@vger.kernel.org Signed-off-by: Denis Efremov --- 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