]> git.baikalelectronics.ru Git - kernel.git/commit
batman-adv: Check ptr for NULL before reducing its refcnt
authorSven Eckelmann <sven@narfation.org>
Sun, 8 Aug 2021 17:56:17 +0000 (19:56 +0200)
committerSimon Wunderlich <sw@simonwunderlich.de>
Fri, 20 Aug 2021 06:17:10 +0000 (08:17 +0200)
commitcb80b7a965035afcea6e17641c842d38262ce6a2
tree4c6df8e72c9d22fdd312be1239b94739f1a24c58
parent5e41fd44e64bd267e933bd2813e030dc5d95c7f0
batman-adv: Check ptr for NULL before reducing its refcnt

The commit 8a32d00ea2a0 ("netdevice: add the case if dev is NULL") changed
the way how the NULL check for net_devices have to be handled when trying
to reduce its reference counter. Before this commit, it was the
responsibility of the caller to check whether the object is NULL or not.
But it was changed to behave more like kfree. Now the callee has to handle
the NULL-case.

The batman-adv code was scanned via cocinelle for similar places. These
were changed to use the paradigm

  @@
  identifier E, T, R, C;
  identifier put;
  @@
   void put(struct T *E)
   {
  + if (!E)
  + return;
   kref_put(&E->C, R);
   }

Functions which were used in other sources files were moved to the header
to allow the compiler to inline the NULL check and the kref_put call.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
14 files changed:
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/distributed-arp-table.c
net/batman-adv/gateway_client.c
net/batman-adv/gateway_client.h
net/batman-adv/hard-interface.h
net/batman-adv/network-coding.c
net/batman-adv/originator.c
net/batman-adv/originator.h
net/batman-adv/soft-interface.c
net/batman-adv/soft-interface.h
net/batman-adv/tp_meter.c
net/batman-adv/translation-table.c
net/batman-adv/translation-table.h
net/batman-adv/tvlv.c