netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ifstat: handle strdup return value
@ 2024-03-14 12:20 Denis Kirjanov
  2024-03-15  2:23 ` Ratheesh Kannoth
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Kirjanov @ 2024-03-14 12:20 UTC (permalink / raw)
  To: stephen, dsahern; +Cc: netdev, Denis Kirjanov

get_nlmsg_extended missing the check as it's done
in get_nlmsg

Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
---
 misc/ifstat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/misc/ifstat.c b/misc/ifstat.c
index 685e66c9..f94b11bc 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -140,6 +140,11 @@ static int get_nlmsg_extended(struct nlmsghdr *m, void *arg)
 
 	n->ifindex = ifsm->ifindex;
 	n->name = strdup(ll_index_to_name(ifsm->ifindex));
+	if (!n->name) {
+		free(n);
+		errno = ENOMEM;
+		return -1;
+	}
 
 	if (sub_type == NO_SUB_TYPE) {
 		memcpy(&n->val, RTA_DATA(tb[filter_type]), sizeof(n->val));
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-15  4:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-14 12:20 [PATCH iproute2] ifstat: handle strdup return value Denis Kirjanov
2024-03-15  2:23 ` Ratheesh Kannoth
2024-03-15  2:34   ` David Ahern
2024-03-15  4:46   ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).