Skip to content

Commit 04f8a3a

Browse files
committed
ip6: fix memory leak when show ip6 router-advert fails
grout# show ip6 router-advert error: command failed: Bad message grout# ^D ==174902==ERROR: LeakSanitizer: detected memory leaks Direct leak of 328 byte(s) in 1 object(s) allocated from: #0 0x7fe0ca6c2250 in calloc (/lib64/libasan.so.8+0xc2250) DPDK#1 0x7fe0cadef910 in scols_new_table (/lib64/libsmartcols.so.1+0x6910) DPDK#2 0x417d0f in ra_show ../modules/ip6/cli/router_advert.c:19 DPDK#3 0x41e836 in exec_strvec ../cli/exec.c:72 DPDK#4 0x41e982 in exec_line ../cli/exec.c:106 DPDK#5 0x41f412 in interact ../cli/interact.c:119 DPDK#6 0x4216db in main ../cli/main.c:167 ... DPDK#9 0x4017f4 in _start (/root/grout/build/grcli+0x4017f4) Only allocate the table if the GR_IP6_IFACE_RA_SHOW api call is successful. Fixes: 8ed8b9d ("ip6: router advertisement configuration") Signed-off-by: Robin Jarry <[email protected]>
1 parent 8be8495 commit 04f8a3a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

modules/ip6/cli/router_advert.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
#include <ecoli.h>
1414
#include <libsmartcols.h>
1515

16-
#include <errno.h>
17-
1816
static cmd_status_t ra_show(const struct gr_api_client *c, const struct ec_pnode *p) {
19-
struct libscols_table *table = scols_new_table();
2017
struct gr_ip6_ra_show_resp *resp;
2118
struct gr_ip6_ra_show_req req;
2219
struct gr_iface iface;
@@ -31,6 +28,7 @@ static cmd_status_t ra_show(const struct gr_api_client *c, const struct ec_pnode
3128
return CMD_ERROR;
3229
resp = resp_ptr;
3330

31+
struct libscols_table *table = scols_new_table();
3432
scols_table_new_column(table, "IFACE", 0, 0);
3533
scols_table_new_column(table, "RA", 0, 0);
3634
scols_table_new_column(table, "interval", 0, 0);

0 commit comments

Comments
 (0)