netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Wu Fengguang <fengguang.wu@intel.com>
Cc: Wang Chen <wangchen@cn.fujitsu.com>,
	David Miller <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Netfilter Development Mailinglist
	<netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH] netfilter: nf_conntrack_sctp: fix build warning
Date: Mon, 24 Nov 2008 13:23:16 +0100	[thread overview]
Message-ID: <492A9CB4.3060004@trash.net> (raw)
In-Reply-To: <20081124011727.GA6462@localhost>

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

Wu Fengguang wrote:
>> print some debug info would be better?
> 
> Like this one?
> +		pr_debug("Empty sctp packet\n");
> 
> Fengguang
> ---
> netfilter: nf_conntrack_sctp: fix build warning
> 
> net/netfilter/nf_conntrack_proto_sctp.c: In function ‘sctp_packet’:
> net/netfilter/nf_conntrack_proto_sctp.c:376: warning: array subscript is above array bounds

The warning is bogus, so we don't need a pr_debug() there.
I've applied your first patch with an unlikely() added and
a comment stating that the warning is bogus.


[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1173 bytes --]

commit a3e2913ffd3dec7f6975f680035670261ad5f56e
Author: Wu Fengguang <wfg@linux.intel.com>
Date:   Mon Nov 24 13:18:00 2008 +0100

    netfilter: nf_conntrack_sctp: fix build warning
    
    net/netfilter/nf_conntrack_proto_sctp.c: In function 'sctp_packet':
    net/netfilter/nf_conntrack_proto_sctp.c:376: warning: array subscript is above array bounds
    
    [Patrick; add unlikely and comment stating that the warning is bogus]
    
    Signed-off-by: Wu Fengguang <wfg@linux.intel.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index c2bd457..1259ec6 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -373,6 +373,12 @@ static int sctp_packet(struct nf_conn *ct,
 	}
 	write_unlock_bh(&sctp_lock);
 
+	/* Avoid bogus warning, gcc doesn't realize do_basic_checks()
+	 * guarantees that there is at least one SCTP chunk.
+	 */
+	if (unlikely(new_state == SCTP_CONNTRACK_MAX))
+		goto out;
+
 	nf_ct_refresh_acct(ct, ctinfo, skb, sctp_timeouts[new_state]);
 
 	if (old_state == SCTP_CONNTRACK_COOKIE_ECHOED &&

       reply	other threads:[~2008-11-24 12:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20081123113315.GA16697@localhost>
     [not found] ` <20081123.135955.202482968.davem@davemloft.net>
     [not found]   ` <20081124000652.GA5424@localhost>
     [not found]     ` <4929FEA9.9090801@cn.fujitsu.com>
     [not found]       ` <20081124011727.GA6462@localhost>
2008-11-24 12:23         ` Patrick McHardy [this message]
2008-11-24 12:35           ` [PATCH] netfilter: nf_conntrack_sctp: fix build warning Wu Fengguang
2008-11-24 12:48             ` Patrick McHardy
2008-11-24 12:50               ` Wu Fengguang

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=492A9CB4.3060004@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=fengguang.wu@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=wangchen@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).