diff mbox series

ipv6: Use local variable for ifa->flags in inet6_fill_ifaddr

Message ID 20241104132434.3101812-1-zilinguan811@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ipv6: Use local variable for ifa->flags in inet6_fill_ifaddr | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-04--18-00 (tests: 781)

Commit Message

Zilin Guan Nov. 4, 2024, 1:24 p.m. UTC
Currently, the inet6_fill_ifaddr() function reads the value of ifa->flags
using READ_ONCE() and stores it in the local variable flags. However,
the subsequent call to put_ifaddrmsg() uses ifa->flags again instead of
the already read local variable. This re-read is unnecessary because
no other thread can modify ifa->flags between the initial READ_ONCE()
and the subsequent use in put_ifaddrmsg().

Signed-off-by: Zilin Guan <zilinguan811@gmail.com>
---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Dumazet Nov. 4, 2024, 1:54 p.m. UTC | #1
On Mon, Nov 4, 2024 at 2:25 PM Zilin Guan <zilinguan811@gmail.com> wrote:
>
> Currently, the inet6_fill_ifaddr() function reads the value of ifa->flags
> using READ_ONCE() and stores it in the local variable flags. However,
> the subsequent call to put_ifaddrmsg() uses ifa->flags again instead of
> the already read local variable. This re-read is unnecessary because
> no other thread can modify ifa->flags between the initial READ_ONCE()
> and the subsequent use in put_ifaddrmsg().

I do not think this last sentence is true. I would rephrase this or remove it.

Otherwise, patch looks fine to me, thanks.


>
> Signed-off-by: Zilin Guan <zilinguan811@gmail.com>
> ---
>  net/ipv6/addrconf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 94dceac52884..c4b080471b39 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -5143,7 +5143,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb,
>                 return -EMSGSIZE;
>
>         flags = READ_ONCE(ifa->flags);
> -       put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
> +       put_ifaddrmsg(nlh, ifa->prefix_len, flags, rt_scope(ifa->scope),
>                       ifa->idev->dev->ifindex);
>
>         if (args->netnsid >= 0 &&
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 94dceac52884..c4b080471b39 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5143,7 +5143,7 @@  static int inet6_fill_ifaddr(struct sk_buff *skb,
 		return -EMSGSIZE;
 
 	flags = READ_ONCE(ifa->flags);
-	put_ifaddrmsg(nlh, ifa->prefix_len, ifa->flags, rt_scope(ifa->scope),
+	put_ifaddrmsg(nlh, ifa->prefix_len, flags, rt_scope(ifa->scope),
 		      ifa->idev->dev->ifindex);
 
 	if (args->netnsid >= 0 &&