diff mbox series

[v1] net/ethtool/tunnels: check the return value of nla_nest_start()

Message ID 20220917022602.3843619-1-floridsleeves@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v1] net/ethtool/tunnels: check the return value of nla_nest_start() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Li Zhong Sept. 17, 2022, 2:26 a.m. UTC
Check the return value of nla_nest_start(), which could be NULL on
error.

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 net/ethtool/tunnels.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jakub Kicinski Sept. 20, 2022, 6:37 p.m. UTC | #1
On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
>  			goto err_cancel_table;
>  
>  		entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
> +		if (!entry)
> +			return -EMSGSIZE;

not even correct, and completely harmless
Li Zhong Sept. 20, 2022, 7:31 p.m. UTC | #2
On Tue, Sep 20, 2022 at 11:37 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
> >                       goto err_cancel_table;
> >
> >               entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
> > +             if (!entry)
> > +                     return -EMSGSIZE;
>
> not even correct, and completely harmless

Thanks for your reply. Maybe a more suitable way of error handling is 'goto
err_cancel_table;'?
Jakub Kicinski Sept. 20, 2022, 7:41 p.m. UTC | #3
On Tue, 20 Sep 2022 12:31:29 -0700 Li Zhong wrote:
> On Tue, Sep 20, 2022 at 11:37 AM Jakub Kicinski <kuba@kernel.org> wrote:
> > On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:  
> > >                       goto err_cancel_table;
> > >
> > >               entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
> > > +             if (!entry)
> > > +                     return -EMSGSIZE;  
> >
> > not even correct, and completely harmless  
> 
> Thanks for your reply. Maybe a more suitable way of error handling is 'goto
> err_cancel_table;'?

Yes, but you _most_ provide the detailed analysis of the impact 
in the commit message for the patches to be considered for merging.
Li Zhong Sept. 21, 2022, 8:31 a.m. UTC | #4
On Tue, Sep 20, 2022 at 12:41 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 20 Sep 2022 12:31:29 -0700 Li Zhong wrote:
> > On Tue, Sep 20, 2022 at 11:37 AM Jakub Kicinski <kuba@kernel.org> wrote:
> > > On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
> > > >                       goto err_cancel_table;
> > > >
> > > >               entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
> > > > +             if (!entry)
> > > > +                     return -EMSGSIZE;
> > >
> > > not even correct, and completely harmless
> >
> > Thanks for your reply. Maybe a more suitable way of error handling is 'goto
> > err_cancel_table;'?
>
> Yes, but you _most_ provide the detailed analysis of the impact
> in the commit message for the patches to be considered for merging.

Thanks for the suggestion. The commit message is updated with more details.
diff mbox series

Patch

diff --git a/net/ethtool/tunnels.c b/net/ethtool/tunnels.c
index efde33536687..90974b625cf6 100644
--- a/net/ethtool/tunnels.c
+++ b/net/ethtool/tunnels.c
@@ -136,6 +136,8 @@  ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base,
 			goto err_cancel_table;
 
 		entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
+		if (!entry)
+			return -EMSGSIZE;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 htons(IANA_VXLAN_UDP_PORT)) ||