[PATCH] Potential memory leak becaue of wrong variable check

Amit Khatri amit.khatri at samsung.com
Thu Aug 31 22:03:38 PDT 2017


From: Amit Khatri <amit.khatri at samsung.com>
Date: Tue, 22 Aug 2017 23:34:50 -0700
Subject: [PATCH] Potential memory leak becaue of wrong variable check.

in rtnl_link_vf_vlan_alloc() function allocating memory to
vlans while checking NULL or not vf_vlans.
it can cause memory leak.

Signed-off-by: Amit Khatri <amit.khatri at samsung.com>
Signed-off-by: Rohit Pratap Singh <rohit.s at samsung.com>
---
 lib/route/link/sriov.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/route/link/sriov.c b/lib/route/link/sriov.c
index b4bc9a7..5c20ecf 100644
--- a/lib/route/link/sriov.c
+++ b/lib/route/link/sriov.c
@@ -1315,7 +1315,7 @@ int rtnl_link_vf_vlan_alloc(nl_vf_vlans_t **vf_vlans, int vlan_count) {
 		return -NLE_INVAL;
 
 	vlans = calloc(1, sizeof(*vlans));
-	if (!vf_vlans)
+	if (!vlans)
 		return -NLE_NOMEM;
 
 	vlan_info = calloc(vlan_count+1, sizeof(*vlan_info));
-- 
1.7.9.5



More information about the libnl mailing list