linux/net/batman-adv
Sven Eckelmann 73f7cbb151 batman-adv: Check ptr for NULL before reducing its refcnt
commit 6340dcbd61 upstream.

The commit b37a466837 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08 14:40:42 +02:00
..
bat_algo.c
bat_algo.h
bat_iv_ogm.c batman-adv: Avoid WARN_ON timing related checks 2021-06-23 14:42:41 +02:00
bat_iv_ogm.h
bat_v_elp.c batman-adv: Migrate to linux/prandom.h 2020-08-18 19:39:54 +02:00
bat_v_elp.h
bat_v_ogm.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-04 21:28:59 -07:00
bat_v_ogm.h
bat_v.c
bat_v.h
bitarray.c
bitarray.h
bridge_loop_avoidance.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
bridge_loop_avoidance.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh 2020-09-15 10:05:24 +02:00
debugfs.c
debugfs.h
distributed-arp-table.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
distributed-arp-table.h batman-adv: remove unused inline function batadv_arp_change_timeout 2020-04-24 15:22:41 +02:00
fragmentation.c batman-adv: Don't always reallocate the fragmentation skb head 2020-11-27 08:02:55 +01:00
fragmentation.h
gateway_client.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
gateway_client.h batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
gateway_common.c
gateway_common.h
hard-interface.c batman-adv: Don't expect inter-netns unique iflink indices 2022-03-08 19:09:33 +01:00
hard-interface.h batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
hash.c
hash.h
icmp_socket.c batadv_socket_read(): get rid of pointless access_ok() 2020-05-20 20:31:33 -04:00
icmp_socket.h
Kconfig
log.c batman-adv: set .owner to THIS_MODULE 2020-11-15 11:43:56 +01:00
log.h batman-adv: Fix typos and grammar in documentation 2020-06-26 10:36:30 +02:00
main.c net: batman-adv: fix error handling 2021-11-02 19:48:22 +01:00
main.h batman-adv: Start new development cycle 2020-08-18 19:39:53 +02:00
Makefile
multicast.c batman-adv: mcast: don't send link-local multicast to mcast routers 2022-01-11 15:25:00 +01:00
multicast.h batman-adv: mcast: don't send link-local multicast to mcast routers 2022-01-11 15:25:00 +01:00
netlink.c batman-adv: allow netlink usage in unprivileged containers 2022-01-27 10:54:11 +01:00
netlink.h
network-coding.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
network-coding.h
originator.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
originator.h batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
routing.c batman-adv: mcast/TT: fix wrongly dropped or rerouted packets 2020-09-05 08:45:46 +02:00
routing.h
send.c batman-adv: Drop repeated words in comments 2020-08-18 19:39:54 +02:00
send.h
soft-interface.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
soft-interface.h batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
sysfs.c batman-adv: Fix refcnt leak in batadv_store_throughput_override 2020-04-21 10:08:05 +02:00
sysfs.h
tp_meter.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
tp_meter.h
trace.c
trace.h
translation-table.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
translation-table.h batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
tvlv.c batman-adv: Check ptr for NULL before reducing its refcnt 2022-04-08 14:40:42 +02:00
tvlv.h
types.h batman-adv: types.h: delete duplicated words 2020-08-18 19:39:53 +02:00