netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: IPv6 routing, NLM_F_* flag support: REPLACE and EXCL
@ 2011-11-15  9:01 Dan Carpenter
  2011-11-15 10:26 ` Matti Vaittinen
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-11-15  9:01 UTC (permalink / raw)
  To: matti.vaittinen; +Cc: netdev

flags support, warn about missing CREATE flag

Hello Matti Vaittinen,

This is a semi-automatic email about new static checker warnings.

The patch 4a287eba2de3: "IPv6 routing, NLM_F_* flag support: REPLACE 
and EXCL flags support, warn about missing CREATE flag" from Nov 14, 
2011, leads to the following Smatch complaint:

net/ipv6/ip6_fib.c +656 fib6_add_rt2node()
	 error: we previously assumed 'info' could be null (see line 641)

net/ipv6/ip6_fib.c
   640		    (info->nlh->nlmsg_flags&NLM_F_REPLACE));
   641		int add = ((NULL == info || NULL == info->nlh) ||
                            ^^^^^^^^^^^^
Checked here.

   642		    (info->nlh->nlmsg_flags&NLM_F_CREATE));
   643		int found = 0;
   644	
   645		ins = &fn->leaf;
   646	
   647		for (iter = fn->leaf; iter; iter=iter->dst.rt6_next) {
   648			/*
   649			 *	Search for duplicates
   650			 */
   651	
   652			if (iter->rt6i_metric == rt->rt6i_metric) {
   653				/*
   654				 *	Same priority level
   655				 */
   656				if (NULL != info->nlh &&
                                            ^^^^^^^^^
Not checked here.  Btw, I looked at the callers and info is always
a valid pointer.

   657				    (info->nlh->nlmsg_flags&NLM_F_EXCL))
   658					return -EEXIST;

regards,
dan carpenter

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

* re: IPv6 routing, NLM_F_* flag support: REPLACE and EXCL
  2011-11-15  9:01 IPv6 routing, NLM_F_* flag support: REPLACE and EXCL Dan Carpenter
@ 2011-11-15 10:26 ` Matti Vaittinen
  0 siblings, 0 replies; 2+ messages in thread
From: Matti Vaittinen @ 2011-11-15 10:26 UTC (permalink / raw)
  To: ext Dan Carpenter; +Cc: netdev

On Tue, 2011-11-15 at 12:01 +0300, ext Dan Carpenter wrote:
> flags support, warn about missing CREATE flag
> 
> Hello Matti Vaittinen,
> 
> This is a semi-automatic email about new static checker warnings.
> 
> The patch 4a287eba2de3: "IPv6 routing, NLM_F_* flag support: REPLACE 
> and EXCL flags support, warn about missing CREATE flag" from Nov 14, 
> 2011, leads to the following Smatch complaint:
> 
> net/ipv6/ip6_fib.c +656 fib6_add_rt2node()
> 	 error: we previously assumed 'info' could be null (see line 641)
> 
> net/ipv6/ip6_fib.c
>    640		    (info->nlh->nlmsg_flags&NLM_F_REPLACE));
>    641		int add = ((NULL == info || NULL == info->nlh) ||
>                             ^^^^^^^^^^^^
> Checked here.
> 
>    642		    (info->nlh->nlmsg_flags&NLM_F_CREATE));

>    656				if (NULL != info->nlh &&
>                                             ^^^^^^^^^
> Not checked here.  Btw, I looked at the callers and info is always
> a valid pointer.

Yes. It really seems the info is always a valid pointer. 
I could find only two places where this info can come from.
First is ip6_ins_rt at route.c where info is allocated from stack. 
Second is ip6_route_add, where info is part of the 
fib6_config struct - and already assumed to be valid.


I'll prepare a patch which removes these unnecessary checks.




-- 
Matti Vaittinen
+358 504863070
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Told a UDP joke the other night...
...but I'm not sure everyone got it...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

end of thread, other threads:[~2011-11-15 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15  9:01 IPv6 routing, NLM_F_* flag support: REPLACE and EXCL Dan Carpenter
2011-11-15 10:26 ` Matti Vaittinen

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).