2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/drivers/net/ethernet/netronome/nfp
Jianglei Nie c56c96303e nfp: Fix memory leak in nfp_cpp_area_cache_add()
In line 800 (#1), nfp_cpp_area_alloc() allocates and initializes a
CPP area structure. But in line 807 (#2), when the cache is allocated
failed, this CPP area structure is not freed, which will result in
memory leak.

We can fix it by freeing the CPP area when the cache is allocated
failed (#2).

792 int nfp_cpp_area_cache_add(struct nfp_cpp *cpp, size_t size)
793 {
794 	struct nfp_cpp_area_cache *cache;
795 	struct nfp_cpp_area *area;

800	area = nfp_cpp_area_alloc(cpp, NFP_CPP_ID(7, NFP_CPP_ACTION_RW, 0),
801 				  0, size);
	// #1: allocates and initializes

802 	if (!area)
803 		return -ENOMEM;

805 	cache = kzalloc(sizeof(*cache), GFP_KERNEL);
806 	if (!cache)
807 		return -ENOMEM; // #2: missing free

817	return 0;
818 }

Fixes: 4cb584e0ee ("nfp: add CPP access core")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Acked-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20211209061511.122535-1-niejianglei2021@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-12-09 07:53:33 -08:00
..
abm net: sched: Merge Qdisc::bstats and Qdisc::cpu_bstats data types 2021-10-18 12:54:41 +01:00
bpf nfp: bpf: relax prog rejection for mtu check through max_pkt_offset 2021-10-28 12:59:32 +01:00
crypto nfp: silence set but not used warning with IPV6=n 2020-12-09 19:42:03 -08:00
flower nfp: flower: Allow ipv6gretap interface for offloading 2021-11-01 13:09:55 +00:00
nfpcore nfp: Fix memory leak in nfp_cpp_area_cache_add() 2021-12-09 07:53:33 -08:00
nic
ccm_mbox.c net: netronome: nfp: Fix wrong function name in comments 2021-05-17 14:12:39 -07:00
ccm.c
ccm.h
devlink_param.c nfp: Move delink_register to be last command 2021-09-27 16:31:59 +01:00
Makefile nfp: flower-ct: add pre and post ct checks 2021-06-02 14:04:41 -07:00
nfp_abi.h
nfp_app_nic.c
nfp_app.c
nfp_app.h drivers: net: ethernet: struct sk_buff is declared duplicately 2021-03-25 17:04:15 -07:00
nfp_asm.c nfp: bpf: silence bitwise vs. logical OR warning 2021-10-18 14:50:01 -07:00
nfp_asm.h
nfp_devlink.c nfp: devlink: initialize the devlink port attribute "lanes" 2021-04-21 10:26:35 -07:00
nfp_hwmon.c
nfp_main.c devlink: Set device as early as possible 2021-08-09 10:21:40 +01:00
nfp_main.h devlink: move request_firmware out of driver 2020-11-19 21:40:57 -08:00
nfp_net_common.c nfp: fix potential deadlock when canceling dim work 2021-10-29 13:25:32 +01:00
nfp_net_ctrl.c
nfp_net_ctrl.h
nfp_net_debugdump.c
nfp_net_debugfs.c
nfp_net_ethtool.c nfp: checking parameter process for rx-usecs/tx-usecs is invalid 2021-11-22 12:44:45 +00:00
nfp_net_main.c ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2021-10-02 14:18:25 +01:00
nfp_net_repr.c nfp: Prefer struct_size over open coded arithmetic 2021-09-13 13:02:38 +01:00
nfp_net_repr.h
nfp_net_sriov.c
nfp_net_sriov.h
nfp_net.h nfp: checking parameter process for rx-usecs/tx-usecs is invalid 2021-11-22 12:44:45 +00:00
nfp_netvf_main.c ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2021-10-02 14:18:25 +01:00
nfp_port.c
nfp_port.h nfp: Replace nfp_pr_et with ethtool_sprintf 2021-03-17 11:42:30 -07:00
nfp_shared_buf.c