backports: fix device_release_driver
PATCH 1/1 backports: fix device_release_driver
From: Johannes Berg <[email protected]>
The new macro, introduced by
commit 9f5876fa9cfb8cd6f450c200043ca7e31915f976
Author: Luis R. Rodriguez <[email protected]> Date: Thu Jul 18 16:40:55 2013 -0700
backports: backport drvdata = NULL core driver fixes
evaluates its argument multiple times, causing crashes as there are potential side-effects of the called code and/or the arguments.
Fix this by converting it to static inlines.
Also remove the driver_probe_device() macro that has the same issue, but tries to wrap a function that isn't even available outside the driver core code in any kernel.
--- backport/backport-include/linux/device.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
backport/backport-include/linux/device.h +9 -16
@@ -177,22 +177,15 @@ extern int dev_set_name(struct device *dev, const char *name, ...)#endif #if LINUX_VERSION_CODE <=KERNEL_VERSION (3 ,6 ,0 ) -#define driver_probe_device (__drv, __dev) \ -({ \ - int ret; \ - ret = (driver_probe_device)(__drv, __dev); \ - if (ret) \ - dev_set_drvdata(__dev, NULL); \ - return ret; \ -}) - -#define device_release_driver (__dev) \ -({ \ - (device_release_driver)(__dev); \ - device_lock(__dev); \ - dev_set_drvdata(__dev, NULL); \ - device_unlock(__dev); \ -}) +static inline void +backport_device_release_driver (struct device *dev) +{ +device_release_driver (dev); +device_lock (dev); +dev_set_drvdata (dev,NULL ); +device_unlock (dev); +} +#define device_release_driver LINUX_BACKPORT(device_release_driver)#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */ #endif /* __BACKPORT_DEVICE_H */
Signature · 1 line
1.8.0
Luis R. Rodriguez
AppliedQuoted 14 lines · Johannes Berg
From: Johannes Berg <[email protected]>
The new macro, introduced by
commit
9f5876fa9cfb8cd6f450c200043ca7e31915f976Author: Luis R. Rodriguez <[email protected]> Date: Thu Jul 18 16:40:55 2013 -0700backports: backport drvdata = NULL core driver fixes
evaluates its argument multiple times, causing crashes as there are potential side-effects of the called code and/or the arguments.
Quoted 7 lines
Fix this by converting it to static inlines.
Also remove the
driver_probe_device()macro that has the same issue, but tries to wrap a function that isn't even available outside the driver core code in any kernel.Signed-off-by Johannes Berg <[email protected]>
Thanks, applied and pushed!
Luis