public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com,
	xiyou.wangcong@gmail.com, mlxsw@mellanox.com,
	sfr@canb.auug.org.au, arnd@arndb.de
Subject: Re: [patch net-next v2] net: sched: silence uninitialized parent variable warning in tc_dump_tfilter
Date: Thu, 18 Jan 2018 17:02:17 +0100	[thread overview]
Message-ID: <20180118160217.GC2063@nanopsycho.orion> (raw)
In-Reply-To: <20180118.103658.1668529956898388197.davem@davemloft.net>

Thu, Jan 18, 2018 at 04:36:58PM CET, davem@davemloft.net wrote:
>From: Jiri Pirko <jiri@resnulli.us>
>Date: Thu, 18 Jan 2018 16:14:49 +0100
>
>> @@ -1317,6 +1317,13 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
>>  		block = tcf_block_lookup(net, tcm->tcm_block_index);
>>  		if (!block)
>>  			goto out;
>> +		/* If we work with block index, q is NULL and parent value
>> +		 * will never be used in the following code. The check
>> +		 * in tcf_fill_node prevents it. However, compiler does not
>> +		 * see that far, so set parent to zero to silence the warning
>> +		 * about parent being uninitialized.
>> +		 */
>> +		parent = 0;
>>  	} else {
>
>Ugh....
>
>Jiri, if you need to add such a verbose comment to explain a compiler
>warning fix, then this code is too complicated for humans to
>understand and audit properly.
>
>And from this perspective I really don't blame the compiler.  Even
>I am still having trouble putting all of these invariants together,
>even considering the information in this comment, in order to see
>how this is "ok".
>
>And even if tcf_fill_node() doesn't access parent, tcf_chain_dump()
>does and stores this uninitialized value into the 'args' if we
>run out of space during the dump.
>
>Yes, I understand that this value will never be used, but wow that
>is propagating an uninitialized value across dump passes.
>
>I've applied this, but please look into restructuring this code
>so that it is a bit more sane in this regard.

Ack. Will try to figure out how to make this saner.

Thanks.

      reply	other threads:[~2018-01-18 16:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18 15:14 [patch net-next v2] net: sched: silence uninitialized parent variable warning in tc_dump_tfilter Jiri Pirko
2018-01-18 15:36 ` David Miller
2018-01-18 16:02   ` Jiri Pirko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180118160217.GC2063@nanopsycho.orion \
    --to=jiri@resnulli.us \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox