aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2021-10-19 01:12:44 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2021-10-19 01:12:44 +0200
commitd44432d6c6c7560263507e9be69b69fe5311ea75 (patch)
treee3083fc4cda9e24265df32e5aa7b122b08037d01
parent55eb97e0a582a9a4562fa2b679f1de372f9f97d5 (diff)
downloadbackports-d44432d6c6c7560263507e9be69b69fe5311ea75.tar.gz
headers: Check for NULL in dev_put() and dev_hold()v5.15-rc6-1
Since kernel 5.15 the dev_put() and dev_hold() functions check if the given dev is not NULL before accessing the pointer. Previously the code to check for NULL was in the calling function. Add this check for NULL because some checks were already removed from the driver code. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--backport/backport-include/linux/netdevice.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h
index 5c30426d..22942398 100644
--- a/backport/backport-include/linux/netdevice.h
+++ b/backport/backport-include/linux/netdevice.h
@@ -151,4 +151,20 @@ struct rtnl_link_stats64 *
bp_dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s);
#endif /* < 4.11 */
+#if LINUX_VERSION_IS_LESS(5,15,0)
+static inline void backport_dev_put(struct net_device *dev)
+{
+ if (dev)
+ dev_put(dev);
+}
+#define dev_put LINUX_BACKPORT(dev_put)
+
+static inline void backport_dev_hold(struct net_device *dev)
+{
+ if (dev)
+ dev_hold(dev);
+}
+#define dev_hold LINUX_BACKPORT(dev_hold)
+#endif /* < 5.15 */
+
#endif /* __BACKPORT_NETDEVICE_H */