Re: [PATCH] netfilter: nf_osf: avoid passing pointer to local var

From: Florian Westphal
Date: Wed Apr 29 2020 - 15:13:03 EST


Arnd Bergmann <arnd@xxxxxxxx> wrote:
> 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.

LGTM, thanks Arnd.

Reviewed-by: Florian Westphal <fw@xxxxxxxxx>