Commit f3ef5317 authored by Zhu Jun's avatar Zhu Jun Committed by Andrii Nakryiko
Browse files

samples/bpf: Fix a resource leak



The opened file should be closed in show_sockopts(), otherwise resource
leak will occur that this problem was discovered by reading code

Signed-off-by: default avatarZhu Jun <zhujun2@cmss.chinamobile.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241010014126.2573-1-zhujun2@cmss.chinamobile.com
parent c6ca3198
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -178,8 +178,10 @@ static int show_sockopts(int family)
		return 1;
	}

	if (get_bind_to_device(sd, name, sizeof(name)) < 0)
	if (get_bind_to_device(sd, name, sizeof(name)) < 0) {
		close(sd);
		return 1;
	}

	mark = get_somark(sd);
	prio = get_priority(sd);