]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_osf: avoid passing pointer to local var
authorArnd Bergmann <arnd@arndb.de>
Wed, 29 Apr 2020 19:00:41 +0000 (21:00 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 29 Apr 2020 19:17:57 +0000 (21:17 +0200)
commit43dc18089560102ccc0ac022422c9c26aadfbae8
treecb7007f33e04965077d04e6df65b3829cded2d2b
parent1eeb2827eff9a75d0b1e2e46fba723bc4efe877e
netfilter: nf_osf: avoid passing pointer to local var

gcc-10 points out that a code path exists where a pointer to a stack
variable may be passed back to the caller:

net/netfilter/nfnetlink_osf.c: In function 'nf_osf_hdr_ctx_init':
cc1: warning: function may return address of local variable [-Wreturn-local-addr]
net/netfilter/nfnetlink_osf.c:171:16: note: declared here
  171 |  struct tcphdr _tcph;
      |                ^~~~~

I am not sure whether this can happen in practice, but moving the
variable declaration into the callers avoids the problem.

Fixes: e84219b8ce31 ("netfilter: nf_osf: add struct nf_osf_hdr_ctx")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nfnetlink_osf.c