Skip to content

Commit 6fc232d

Browse files
Aditya Pakkijmberg-intel
authored andcommitted
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>
1 parent 911bde0 commit 6fc232d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎net/rfkill/core.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,13 @@ static void rfkill_sync_work(struct work_struct *work)
10021002
int __must_check rfkill_register(struct rfkill *rfkill)
10031003
{
10041004
static unsigned long rfkill_no;
1005-
struct device *dev = &rfkill->dev;
1005+
struct device *dev;
10061006
int error;
10071007

1008-
BUG_ON(!rfkill);
1008+
if (!rfkill)
1009+
return -EINVAL;
1010+
1011+
dev = &rfkill->dev;
10091012

10101013
mutex_lock(&rfkill_global_mutex);
10111014

0 commit comments

Comments
 (0)