Return-path: Received: from rnd-relay.smtp.broadcom.com ([192.19.229.170]:48338 "EHLO rnd-relay.smtp.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752482AbeEPMMe (ORCPT ); Wed, 16 May 2018 08:12:34 -0400 From: Arend van Spriel To: Kalle Valo Cc: linux-wireless@vger.kernel.org, Franky Lin , Arend van Spriel Subject: [PATCH V2 4/6] brcmfmac: validate user provided data for memdump before copying Date: Wed, 16 May 2018 14:12:01 +0200 Message-Id: <1526472723-15758-5-git-send-email-arend.vanspriel@broadcom.com> (sfid-20180516_141242_663373_3EE9053D) In-Reply-To: <1526472723-15758-1-git-send-email-arend.vanspriel@broadcom.com> References: <1526472723-15758-1-git-send-email-arend.vanspriel@broadcom.com> Sender: linux-wireless-owner@vger.kernel.org List-ID: From: Franky Lin In patch "brcmfmac: add support for sysfs initiated coredump", a new scenario of brcmf_debug_create_memdump was added in which the user of the function might not necessarily provide prefix data. Hence the function should not assume the data is always valid and should perform a check before copying. Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: Arend van Spriel --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c index 5048320..489b5df 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c @@ -40,7 +40,8 @@ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, if (!dump) return -ENOMEM; - memcpy(dump, data, len); + if (data && len > 0) + memcpy(dump, data, len); err = brcmf_bus_get_memdump(bus, dump + len, ramsize); if (err) { vfree(dump); -- 1.9.1