From 31679da96fc33b69d68edeabd03861ff00417924 Mon Sep 17 00:00:00 2001 From: Muhammad Husaini Zulkifli Date: Tue, 3 Aug 2021 08:49:34 +0800 Subject: [PATCH] rtnetlink: Add return value check This patch add return value checking for both of the nla_put_u32() and nla_put_u8() in rtnl_xdp_fill(). Signed-off-by: Muhammad Husaini Zulkifli Signed-off-by: Aravindhan Gunasekaran --- net/core/rtnetlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index b42f391b9e82..6f959d81ea8e 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1531,8 +1531,12 @@ static int rtnl_xdp_fill(struct sk_buff *skb, struct net_device *dev) if (!md_btf_id) goto err_cancel; - nla_put_u32(skb, IFLA_XDP_MD_BTF_ID, md_btf_id); - nla_put_u8(skb, IFLA_XDP_MD_BTF_STATE, md_btf_enabled); + err = nla_put_u32(skb, IFLA_XDP_MD_BTF_ID, md_btf_id); + if (err) + goto err_cancel; + err = nla_put_u8(skb, IFLA_XDP_MD_BTF_STATE, md_btf_enabled); + if (err) + goto err_cancel; nla_nest_end(skb, xdp); return 0;