mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 08:31:55 +00:00
brcmfmac: check memory allocation in brcmf_add_if()
For P2P_DEVICE interface the struct brcmf_if instance is allocated using kzalloc() which can fail. Add pointer check and return -ENOMEM if it failed. Fixes the following smatch error: "drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c:770 brcmf_add_if() error: potential null dereference 'ifp'. (kzalloc returns null)" Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reported-by: Fengguang Wu <fengguang.wu@intel.com> Reviewed-by: Hante Meuleman <meuleman@broadcom.com> Reviewed-by: Piotr Haber <phaber@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
07529d2047
commit
991c209393
@ -754,6 +754,8 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bssidx, s32 ifidx,
|
||||
/* this is P2P_DEVICE interface */
|
||||
brcmf_dbg(INFO, "allocate non-netdev interface\n");
|
||||
ifp = kzalloc(sizeof(*ifp), GFP_KERNEL);
|
||||
if (!ifp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
} else {
|
||||
brcmf_dbg(INFO, "allocate netdev interface\n");
|
||||
/* Allocate netdev, including space for private structure */
|
||||
|
Loading…
Reference in New Issue
Block a user