summaryrefslogtreecommitdiff
path: root/net/rfkill
diff options
context:
space:
mode:
authorAditya Pakki <pakki001@umn.edu>2019-12-15 18:34:08 +0300
committerJohannes Berg <johannes.berg@intel.com>2019-12-16 12:15:49 +0300
commit6fc232db9e8cd50b9b83534de9cd91ace711b2d7 (patch)
treebd8372886f47dbe86bd837f5ad794d2d545544f2 /net/rfkill
parent911bde0fe5ccd7e55760be9d6dcc67a8850fcc12 (diff)
downloadlinux-6fc232db9e8cd50b9b83534de9cd91ace711b2d7.tar.xz
rfkill: Fix incorrect check to avoid NULL pointer dereference
In rfkill_register, the struct rfkill pointer is first derefernced and then checked for NULL. This patch removes the BUG_ON and returns an error to the caller in case rfkill is NULL. Signed-off-by: Aditya Pakki <pakki001@umn.edu> Link: https://lore.kernel.org/r/20191215153409.21696-1-pakki001@umn.edu Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/rfkill')
-rw-r--r--net/rfkill/core.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 461d75274fb3..971c73c7d34c 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1002,10 +1002,13 @@ static void rfkill_sync_work(struct work_struct *work)
int __must_check rfkill_register(struct rfkill *rfkill)
{
static unsigned long rfkill_no;
- struct device *dev = &rfkill->dev;
+ struct device *dev;
int error;
- BUG_ON(!rfkill);
+ if (!rfkill)
+ return -EINVAL;
+
+ dev = &rfkill->dev;
mutex_lock(&rfkill_global_mutex);