Message ID | 20240227080613.34001-1-duoming@zju.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-82841-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2554721dyb; Tue, 27 Feb 2024 00:07:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXIn3534xP2k8JX2kDtfsgNyvJfrwt5RW0QM+o2HnaT1XNDCi+ANffBK443POIE4zeeWp72ZVJ0/iokbN0cHaa/h2I6tw== X-Google-Smtp-Source: AGHT+IEy6MKI91DAjqhdtB64qdHZ+Cx/+K3o53w/9RTLfr0HwBuX1CDg3Aqt/NH3IYOq3TGhe0Zq X-Received: by 2002:a17:90a:8a89:b0:299:36f0:a401 with SMTP id x9-20020a17090a8a8900b0029936f0a401mr6393079pjn.42.1709021266893; Tue, 27 Feb 2024 00:07:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709021266; cv=pass; d=google.com; s=arc-20160816; b=PnCStKQDgktX9QwL9V82PV77wvrdvNvXU3HGgmbICmxv4E7zU96QRgUctqbZW2XW/j U81a1CKX4LsAunBcUV3YYMc4Qiy2VLNrrKMb5CLEK8D7mdrp41KCJF3Gvs2r9klhRbBt y9Uknel5iMfzCz8pCYmTABb16Gufbh6lMjgW2g7ldjiE2eU7phJKWFUSXFEJTTWJfScZ WeSfMqOv2XJez/XhVKFcimCOW/ktoGp8Dr2H0+2MSs898uUJXOMEiC/5CAuX4qtsPovq LT3mWpW3sCOzGYdMvvZC9Tc4wNpakYGxs42KdQeppLbUY0/1ugy3rXjp7/GGfaenHcQm dkyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=4exX239yuAAfBRtBg+QiMYwbpiyfHLsIACKXnw9xSXo=; fh=b7ReMrLBFXqAEwFs/k9HSNaqYHbbQ2Oh9PuH+N3kmE4=; b=GsHx+6mJTFWmZtJhRTeHqPDVlJXFwdh+T1ZQvJTSQBia/ibkCWKJVfNAVP4bZEpPHi HqPk05jtpFkbxauNhjT2USd/ClMSi4tefaKVn1JGuf83EvnCJHFgUVlyuwfwbMjo8Gt0 QcWaKBDFXxN+ydmSkL0uBCiQfnFrnjXbRfkH9kuCVH1VVavSQg+G4Ahd9goP8lKgCfym nFAMuNYkLhsVj0fuqOnGlGDMC40KqbPT9LIaDHfUMs/Zfbdcgfn9nQn9OX8Lp5j5U1Al RoyIYQpxQ8gODzEZfDWjOzV1ndJku2E7ZPgog38tpS+os+/wuEvPmoUmWpBSkTiZjp3J kO4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-82841-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82841-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u9-20020a634549000000b005d8bf0a91besi5071046pgk.276.2024.02.27.00.07.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 00:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82841-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-82841-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82841-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id ED842286757 for <ouuuleilei@gmail.com>; Tue, 27 Feb 2024 08:07:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEBC356770; Tue, 27 Feb 2024 08:07:06 +0000 (UTC) Received: from zg8tmtu5ljg5lje1ms4xmtka.icoremail.net (zg8tmtu5ljg5lje1ms4xmtka.icoremail.net [159.89.151.119]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C36255E62; Tue, 27 Feb 2024 08:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.89.151.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709021225; cv=none; b=QiDiFaPeMALAwbQmpiOg1hRX+CUigXqluWwJG24T5K1EY3e3k+mfPnaFsqgd0ahQ6jiYH5BH+fuyMVB6RhncOwgKSOhgn24/+i7K/U6pbFl0OlqiU8PKG0vExIRXCKcvy/G6tTZu5DnPzzo8LwSiUmNwXjZU9G2Ie2KH1//10O8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709021225; c=relaxed/simple; bh=bn8lBdZvB6L2HQkh78StuFH3Cwbf8lGTxYiUbBqrdUk=; h=From:To:Cc:Subject:Date:Message-Id; b=MhhROsfbMTK/tFR0hsqv/aZepUxNNg7ynpxeqw/tAaq3N0d8qbgbUP4rnmQaogheUqC+Y/hjNaw3Ff7SiYJwgrIzcqk9F30Srk41P3aTiTY13g0WWY3JjDERaAPQRK11jd/jVUTLTY4dFTQ6Mk3F6Fhr61g+8QT+VgtwuT6Ydo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=159.89.151.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from ubuntu.localdomain (unknown [218.12.19.154]) by mail-app2 (Coremail) with SMTP id by_KCgBnF6b2l91l841JAg--.21305S2; Tue, 27 Feb 2024 16:06:27 +0800 (CST) From: Duoming Zhou <duoming@zju.edu.cn> To: linux-kernel@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com, brcm80211@lists.linux.dev, linux-wireless@vger.kernel.org, justinstitt@google.com, john@keeping.me.uk, quic_alokad@quicinc.com, marcan@marcan.st, johannes.berg@intel.com, linus.walleij@linaro.org, kvalo@kernel.org, arend.vanspriel@broadcom.com, Duoming Zhou <duoming@zju.edu.cn> Subject: [PATCH] wifi: brcm80211: handle pmk_op allocation failure Date: Tue, 27 Feb 2024 16:06:13 +0800 Message-Id: <20240227080613.34001-1-duoming@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: by_KCgBnF6b2l91l841JAg--.21305S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZF43XrW3XrWUAry8Wr13twb_yoW8GFWkpw s7GFyqyr1UWw4Skw45tFyvvryFga17K3sYkr4jy3s3uFZ3Gr1rJr48KFyFvFnYyr4ay3y2 vFWktF98Wr4DWw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9j14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26rxl 6s0DM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4 AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE 17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMI IF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4l IxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvf C2KfnxnUUI43ZEXa7VUbGQ6JUUUUU== X-CM-SenderInfo: qssqjiasttq6lmxovvfxof0/1tbiAwQEAWXc3dIQZQAcsd Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792038683596526745 X-GMAIL-MSGID: 1792038683596526745 |
Series |
wifi: brcm80211: handle pmk_op allocation failure
|
|
Commit Message
Duoming Zhou
Feb. 27, 2024, 8:06 a.m. UTC
The kzalloc() in brcmf_pmksa_v3_op() will return null if the
physical memory has run out. As a result, if we dereference
the null value, the null pointer dereference bug will happen.
Return -ENOMEM from brcmf_pmksa_v3_op() if kzalloc() fails
for pmk_op.
Fixes: a96202acaea4 ("wifi: brcmfmac: cfg80211: Add support for PMKID_V3 operations")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On 2/27/2024 9:06 AM, Duoming Zhou wrote: > The kzalloc() in brcmf_pmksa_v3_op() will return null if the > physical memory has run out. As a result, if we dereference > the null value, the null pointer dereference bug will happen. > > Return -ENOMEM from brcmf_pmksa_v3_op() if kzalloc() fails > for pmk_op. NAK (see below) Also this issue was reported earlier by Joe Perches. Not sure if he wants to be mentioned as such. > Fixes: a96202acaea4 ("wifi: brcmfmac: cfg80211: Add support for PMKID_V3 operations") > Signed-off-by: Duoming Zhou <duoming@zju.edu.cn> > --- > drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > index 28d6a30cc01..3b420b33188 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > @@ -4322,6 +4322,10 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, > int ret; > > pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL); > + if (!pmk_op) { > + ret = -ENOMEM; > + goto out; > + } There is really no need to introduce a new label for this. Although you can kfree() a NULL pointer there is no need to do so when you know already it is NULL. Just return -ENOMEM and be done with it. Regards, Arend > pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3); > > if (!pmksa) { > @@ -4340,6 +4344,7 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, > pmk_op->length = cpu_to_le16(length); > > ret = brcmf_fil_iovar_data_set(ifp, "pmkid_info", pmk_op, sizeof(*pmk_op)); > +out: > kfree(pmk_op); > return ret; > }
On Tue, 2024-02-27 at 12:21 +0100, Arend van Spriel wrote: > On 2/27/2024 9:06 AM, Duoming Zhou wrote: > > The kzalloc() in brcmf_pmksa_v3_op() will return null if the > > physical memory has run out. As a result, if we dereference > > the null value, the null pointer dereference bug will happen. > > > > Return -ENOMEM from brcmf_pmksa_v3_op() if kzalloc() fails > > for pmk_op. > > NAK (see below) > > Also this issue was reported earlier by Joe Perches. Not sure if he > wants to be mentioned as such. I think it's unimportant to be mentioned. I think it's more important that the code be researched that the simple return of -ENOMEM the appropriate fix and is handled by all possible callers of the function. > > > Fixes: a96202acaea4 ("wifi: brcmfmac: cfg80211: Add support for PMKID_V3 operations") > > Signed-off-by: Duoming Zhou <duoming@zju.edu.cn> > > --- > > drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.cq b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > > index 28d6a30cc01..3b420b33188 100644 > > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > > @@ -4322,6 +4322,10 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, > > int ret; > > > > pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL); > > + if (!pmk_op) { > > + ret = -ENOMEM; > > + goto out; > > + } > > There is really no need to introduce a new label for this. Although you > can kfree() a NULL pointer there is no need to do so when you know > already it is NULL. Just return -ENOMEM and be done with it. > > Regards, > Arend > > > pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3); > > > > if (!pmksa) { > > @@ -4340,6 +4344,7 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, > > pmk_op->length = cpu_to_le16(length); > > > > ret = brcmf_fil_iovar_data_set(ifp, "pmkid_info", pmk_op, sizeof(*pmk_op)); > > +out: > > kfree(pmk_op); > > return ret; > > }
On Tue, 27 Feb 2024 03:42:13 -0800 Joe Perches wrote: > > > The kzalloc() in brcmf_pmksa_v3_op() will return null if the > > > physical memory has run out. As a result, if we dereference > > > the null value, the null pointer dereference bug will happen. > > > > > > Return -ENOMEM from brcmf_pmksa_v3_op() if kzalloc() fails > > > for pmk_op. > > > > NAK (see below) > > > > Also this issue was reported earlier by Joe Perches. Not sure if he > > wants to be mentioned as such. > > I think it's unimportant to be mentioned. > > I think it's more important that the code be researched > that the simple return of -ENOMEM the appropriate fix > and is handled by all possible callers of the function. There are three functions that call the brcmf_pmksa_v3_op(), including brcmf_cfg80211_set_pmksa(), brcmf_cfg80211_del_pmksa() and brcmf_cfg80211_flush_pmksa(). The return type of the above three functions is s32. If brcmf_pmksa_v3_op() returns -ENOMEM, the above three functions will also return -ENOMEM. It could be handled appropriately by the callers of the function. So I think the simple return of -ENOMEM is appropriate. > > > Fixes: a96202acaea4 ("wifi: brcmfmac: cfg80211: Add support for PMKID_V3 operations") > > > Signed-off-by: Duoming Zhou <duoming@zju.edu.cn> > > > --- > > > drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.cq b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > > > index 28d6a30cc01..3b420b33188 100644 > > > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > > > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > > > @@ -4322,6 +4322,10 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, > > > int ret; > > > > > > pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL); > > > + if (!pmk_op) { > > > + ret = -ENOMEM; > > > + goto out; > > > + } > > > > There is really no need to introduce a new label for this. Although you > > can kfree() a NULL pointer there is no need to do so when you know > > already it is NULL. Just return -ENOMEM and be done with it. > > > > Regards, > > Arend > > > > > pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3); > > > > > > if (!pmksa) { > > > @@ -4340,6 +4344,7 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, > > > pmk_op->length = cpu_to_le16(length); > > > > > > ret = brcmf_fil_iovar_data_set(ifp, "pmkid_info", pmk_op, sizeof(*pmk_op)); > > > +out: > > > kfree(pmk_op); > > > return ret; > > > } Best regards, Duoming Zhou
On 2/27/2024 12:42 PM, Joe Perches wrote: > On Tue, 2024-02-27 at 12:21 +0100, Arend van Spriel wrote: >> On 2/27/2024 9:06 AM, Duoming Zhou wrote: >>> The kzalloc() in brcmf_pmksa_v3_op() will return null if the >>> physical memory has run out. As a result, if we dereference >>> the null value, the null pointer dereference bug will happen. >>> >>> Return -ENOMEM from brcmf_pmksa_v3_op() if kzalloc() fails >>> for pmk_op. >> >> NAK (see below) >> >> Also this issue was reported earlier by Joe Perches. Not sure if he >> wants to be mentioned as such. > > I think it's unimportant to be mentioned. > > I think it's more important that the code be researched > that the simple return of -ENOMEM the appropriate fix > and is handled by all possible callers of the function. Right. That is what I did after which I replied on Feb 18 to your email. https://lore.kernel.org/all/3e1f11b3-a689-4c8e-bfda-b43649db7106@broadcom.com/ Regards, Arend >> >>> Fixes: a96202acaea4 ("wifi: brcmfmac: cfg80211: Add support for PMKID_V3 operations") >>> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn> >>> --- >>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++ >>> 1 file changed, 5 insertions(+) >>> >>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.cq b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c >>> index 28d6a30cc01..3b420b33188 100644 >>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c >>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c >>> @@ -4322,6 +4322,10 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, >>> int ret; >>> >>> pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL); >>> + if (!pmk_op) { >>> + ret = -ENOMEM; >>> + goto out; >>> + } >> >> There is really no need to introduce a new label for this. Although you >> can kfree() a NULL pointer there is no need to do so when you know >> already it is NULL. Just return -ENOMEM and be done with it. >> >> Regards, >> Arend >> >>> pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3); >>> >>> if (!pmksa) { >>> @@ -4340,6 +4344,7 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, >>> pmk_op->length = cpu_to_le16(length); >>> >>> ret = brcmf_fil_iovar_data_set(ifp, "pmkid_info", pmk_op, sizeof(*pmk_op)); >>> +out: >>> kfree(pmk_op); >>> return ret; >>> } >
On Tue, 2024-02-27 at 20:40 +0100, Arend van Spriel wrote: > On 2/27/2024 12:42 PM, Joe Perches wrote: > > On Tue, 2024-02-27 at 12:21 +0100, Arend van Spriel wrote: > > > On 2/27/2024 9:06 AM, Duoming Zhou wrote: > > > > The kzalloc() in brcmf_pmksa_v3_op() will return null if the > > > > physical memory has run out. As a result, if we dereference > > > > the null value, the null pointer dereference bug will happen. > > > > > > > > Return -ENOMEM from brcmf_pmksa_v3_op() if kzalloc() fails > > > > for pmk_op. > > > > > > NAK (see below) > > > > > > Also this issue was reported earlier by Joe Perches. Not sure if he > > > wants to be mentioned as such. > > > > I think it's unimportant to be mentioned. > > > > I think it's more important that the code be researched > > that the simple return of -ENOMEM the appropriate fix > > and is handled by all possible callers of the function. > > Right. That is what I did after which I replied on Feb 18 to your email. > > https://lore.kernel.org/all/3e1f11b3-a689-4c8e-bfda-b43649db7106@broadcomcom/ > Right, I did that as well, but I didn't look up the entire calling tree. It likely works. It's also likely better than the write through of the null pointer.
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 28d6a30cc01..3b420b33188 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -4322,6 +4322,10 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, int ret; pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL); + if (!pmk_op) { + ret = -ENOMEM; + goto out; + } pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3); if (!pmksa) { @@ -4340,6 +4344,7 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa, pmk_op->length = cpu_to_le16(length); ret = brcmf_fil_iovar_data_set(ifp, "pmkid_info", pmk_op, sizeof(*pmk_op)); +out: kfree(pmk_op); return ret; }