Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6992900ybn; Mon, 30 Sep 2019 07:05:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT5IplsPVmhAsLlSDl6Knx4TSMGn6XdCy9wAo/F4dZgFEmIJRGvR1lS8/by0HlX9yyiYuJ X-Received: by 2002:a17:906:d797:: with SMTP id pj23mr19618991ejb.70.1569852338280; Mon, 30 Sep 2019 07:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569852338; cv=none; d=google.com; s=arc-20160816; b=SC1C37CZ3WWc1Gcnj446xIWeesahHnoDU7sYviU1QhJ2KBuXiboblhpNkRjYZ4wg+E yX/IoJNbsM9FhXraaRP864Qqam/S/Ls5Lku9G/PwJliy02FSEe6wAwwBXLiSwjKQ2Kgt VLFwodxeXod7HU8Fh5SGt7SCDVDaq0z/tA6lEC0wKOJQt2jrRW9DnPQQbXYqqpr0zIO8 GcH0X0LRugLaBRhTj76l72xxcE//V/USwgxRhNDXBeQnfYCR4zQBCMFoc1uY8pU2SVKO 70Sj8+f8BOWt+nI6SkUE4j8XL6lK1qD51gIWn8VWkVkKOrtT3zeNcziGHC0+NUvlm/97 H1xQ== 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 :message-id:date:subject:cc:to:from; bh=7wr4aVdaxbEMv/UX7nqpmCIH8uVZ65LnsbgEKWRrbhc=; b=gS91QG9ElzWactI7YTiN2YJQKpfftdwutC1EIATIIWGWeD2C2SF3t1W/gsbBMGtVBE xlhtDbUpaAehJd0VdhWP4bM50IBuJigPcHGwNHnXLEV3iRCVlTBTEOOzPiMH3+RwbPpA E2+uiZnM8yJNqKuyOOPNXYy8vM8ENLUpjfHEHAS9FWc9vm3W84F1Sn07NKmP1NbavDug 9kitnXLxhj/ghYI5CrX6JZSkc4lxTIU74iXkPkpYTimNrIzAItzpArEfUfhBxPzdN8v0 QxEltup1T8uhY1kyVHxy/evYzZNoWeWA0lf3PMBpwUsZUWMLrox1XO7ca/dmgumAQlsk zJJw== 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 u2si6781459ejr.332.2019.09.30.07.05.11; Mon, 30 Sep 2019 07:05:38 -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 S1731477AbfI3OCZ (ORCPT + 99 others); Mon, 30 Sep 2019 10:02:25 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33350 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730524AbfI3OCY (ORCPT ); Mon, 30 Sep 2019 10:02:24 -0400 Received: by mail-wr1-f68.google.com with SMTP id b9so11513358wrs.0; Mon, 30 Sep 2019 07:02:22 -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=7wr4aVdaxbEMv/UX7nqpmCIH8uVZ65LnsbgEKWRrbhc=; b=RtpRwsDwr1LTPoUq5NUM+nrpO63VDB1OLtLqQP7qiOq+hIhz/UcRSEGmSbXxAtwsjE J3UWgjASH3/BrHk1TMxdacLaOBoktTsDOEtn7Bc3RTkw3otK69yq577gHe5zj2TL3RYl qPjcCJnVjNslaG/FPUKEB17jbDRVyBOJvJ6eCwGa/TPf54WVCKZoEsEFQm1ffBy50sPe SfoEkzVC9OjnUwkRAL+b6XHHa26ITQYP5fkZqK7WtJKYhIKcOj+mRnjZOuAKp58vnEeJ +pfoxMcCxVjb0Y+T0v9tax75iJHH0nftbeEe4ih3Odgw7hvF0lld2FXmxbux0mGEeffJ 3Gmg== X-Gm-Message-State: APjAAAXE4cLZ2KsXFJtau9qgz9t7dKlbQeZYKtsQGDelB4XIUDB6bY/j DKaP6403EQI4pZfbxk7q7UlpAntC X-Received: by 2002:adf:b648:: with SMTP id i8mr12771912wre.372.1569852142160; Mon, 30 Sep 2019 07:02:22 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id x129sm20494089wmg.8.2019.09.30.07.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 07:02:21 -0700 (PDT) From: Denis Efremov To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Denis Efremov , Pontus Fuchs , Kalle Valo , "David S. Miller" , stable@vger.kernel.org Subject: [PATCH] ar5523: check NULL before memcpy() in ar5523_cmd() Date: Mon, 30 Sep 2019 17:02:07 +0300 Message-Id: <20190930140207.28638-1-efremov@linux.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org memcpy() call with "idata == NULL && ilen == 0" results in undefined behavior in ar5523_cmd(). For example, NULL is passed in callchain "ar5523_stat_work() -> ar5523_cmd_write() -> ar5523_cmd()". This patch adds idata check before memcpy() call in ar5523_cmd() to prevent an undefined behavior. Cc: Pontus Fuchs Cc: Kalle Valo Cc: "David S. Miller" Cc: stable@vger.kernel.org Signed-off-by: Denis Efremov --- drivers/net/wireless/ath/ar5523/ar5523.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c index b94759daeacc..f25af5bc5282 100644 --- a/drivers/net/wireless/ath/ar5523/ar5523.c +++ b/drivers/net/wireless/ath/ar5523/ar5523.c @@ -255,7 +255,8 @@ static int ar5523_cmd(struct ar5523 *ar, u32 code, const void *idata, if (flags & AR5523_CMD_FLAG_MAGIC) hdr->magic = cpu_to_be32(1 << 24); - memcpy(hdr + 1, idata, ilen); + if (idata) + memcpy(hdr + 1, idata, ilen); cmd->odata = odata; cmd->olen = olen; -- 2.21.0