[v1] net/nfp: fix dangling pointer on failure

Message ID 1586259447-13508-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v1] net/nfp: fix dangling pointer on failure |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Yunjian Wang April 7, 2020, 11:37 a.m. UTC
  From: Yunjian Wang <wangyunjian@huawei.com>

When nfp_pf_create_dev() is cleaning up, it does not correctly set
the dev_private variable to NULL, which will lead to a double free.

Fixes: ef28aa96e53b ("net/nfp: support multiprocess")
CC: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/nfp/nfp_net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Heinrich Kuhn April 7, 2020, 1:44 p.m. UTC | #1
On 2020/04/07 13:37, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> When nfp_pf_create_dev() is cleaning up, it does not correctly set
> the dev_private variable to NULL, which will lead to a double free.
> 
> Fixes: ef28aa96e53b ("net/nfp: support multiprocess")
> CC: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Thanks Yunjian

Acked-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
  
Ferruh Yigit April 8, 2020, 11:22 a.m. UTC | #2
On 4/7/2020 2:44 PM, Heinrich Kuhn wrote:
> 
> 
> On 2020/04/07 13:37, wangyunjian wrote:
>> From: Yunjian Wang <wangyunjian@huawei.com>
>>
>> When nfp_pf_create_dev() is cleaning up, it does not correctly set
>> the dev_private variable to NULL, which will lead to a double free.
>>
>> Fixes: ef28aa96e53b ("net/nfp: support multiprocess")
>> CC: stable@dpdk.org
>>
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> 
> Thanks Yunjian
> 
> Acked-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 64d9d218d..6e24a09a2 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3451,9 +3451,10 @@  nfp_pf_create_dev(struct rte_pci_device *dev, int port, int ports,
 probe_failed:
 	rte_free(port_name);
 	/* free ports private data if primary process */
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		rte_free(eth_dev->data->dev_private);
-
+		eth_dev->data->dev_private = NULL;
+	}
 	rte_eth_dev_release_port(eth_dev);
 
 	return retval;