lkml.org 
[lkml]   [2020]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.19 41/84] rfkill: Fix incorrect check to avoid NULL pointer dereference
Hi!

> From: Aditya Pakki <pakki001@umn.edu>
>
> [ Upstream commit 6fc232db9e8cd50b9b83534de9cd91ace711b2d7 ]
>
> 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.

I don't see the dereference; address of field in structure is taken,
but that does not need a dereference. Not sure if it is valid C, but
I'm pretty sure it does not cause any problems.

Plus I wonder if this is a good idea. Noone should be doing
rfkill_register(NULL)...

Best regards,
Pavel

> @@ -1014,10 +1014,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);
>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-01-13 09:09    [W:0.289 / U:4.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site