Re: [PATCH 4.19 41/84] rfkill: Fix incorrect check to avoid NULL pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

> From: Aditya Pakki <pakki001@xxxxxxx>
> 
> [ 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

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux