ipv4: Don't allocate ifa for 0.0.0.0 in inet_rtm_newaddr().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Mon, 21 Oct 2024 18:32:31 +0000 (11:32 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 29 Oct 2024 10:54:57 +0000 (11:54 +0100)
commitabd0deff03d854cb34818e1e01490296d0314ea1
tree92a204ad421c44780c4140b2c53d8f44df617863
parent2d34429d14f9d09b38a8bee6a972a07228378df6
ipv4: Don't allocate ifa for 0.0.0.0 in inet_rtm_newaddr().

When we pass 0.0.0.0 to __inet_insert_ifa(), it frees ifa and returns 0.

We can do this check much earlier for RTM_NEWADDR even before allocating
struct in_ifaddr.

Let's move the validation to

  1. inet_insert_ifa() for ioctl()
  2. inet_rtm_newaddr() for RTM_NEWADDR

Now, we can remove the same check in find_matching_ifa().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/ipv4/devinet.c