linux_dsm_epyc7002/drivers/net/ethernet/cavium/thunder
Aleksey Makarov 3d67a50752 net: thunderx: fix double free error
This patch fixes an error in memory allocation/freeing in
ThunderX PF driver.

I moved the allocation to the probe() function and made it managed.

>From the Colin's email:

While running static analysis on linux-next with CoverityScan I found 3
double free errors in the Cavium thunder driver.

The issue occurs on the err_disable_device: label of function nic_probe
when nic_free_lmacmem(nic) is called and a double free occurs on
nic->duplex, nic->link and nic->speed.  This occurs when nic_init_hw()
fails:

        /* Initialize hardware */
        err = nic_init_hw(nic);
        if (err)
                goto err_release_regions;

nic_init_hw() calls nic_get_hw_info() and this calls nic_free_lmacmem()
if any of the allocations fail. This free'ing occurs again by the call
to nic_free_lmacmem() on the err_release_regions exit path in nic_probe().

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Aleksey Makarov <aleksey.makarov@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-11-11 19:22:34 +09:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nic_main.c net: thunderx: fix double free error 2017-11-11 19:22:34 +09:00
nic_reg.h net: thunderx: Program LMAC credits based on MTU 2016-11-16 13:28:33 -05:00
nic.h net: thunderx: Add basic XDP support 2017-05-02 15:41:21 -04:00
nicvf_ethtool.c net: thunderx: Add basic XDP support 2017-05-02 15:41:21 -04:00
nicvf_main.c net: bpf: rename ndo_xdp to ndo_bpf 2017-11-05 22:26:18 +09:00
nicvf_queues.c cavium: thunder: Remove duplicate "netdev->name" logging output 2017-06-29 12:25:33 -04:00
nicvf_queues.h net: define the TSO header size in net/tso.h 2017-08-23 20:42:09 -07:00
q_struct.h net: thunderx: Optimize RBDR descriptor handling 2017-05-02 15:41:20 -04:00
thunder_bgx.c net: thunderx: Fix BGX transmit stall due to underflow 2017-07-29 14:17:07 -07:00
thunder_bgx.h net: thunderx: Fix BGX transmit stall due to underflow 2017-07-29 14:17:07 -07:00
thunder_xcv.c net: thunderx: avoid dereferencing xcv when NULL 2017-01-31 13:07:40 -05:00