Re: [PATCH-3.5.y] staging: comedi: pcmuio: fix possible NULL deref on detach

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

 



On Thu, Dec 12, 2013 at 01:21:59PM +0000, Ian Abbott wrote:
> follow 2fd2bdfccae61efe18f6b92b6a45fbf936d75b48

Thanks Ian, I'm queuing it for the 3.5 kernel.

Cheers,
--
Luis

> 
> pcmuio_detach() is called by the comedi core even if pcmuio_attach()
> returned an error, so `dev->private` might be `NULL`.  Check for that
> before dereferencing it.
> 
> Also, as pointed out by Dan Carpenter, there is no need to check the
> pointer passed to `kfree()` is non-NULL, so remove that check.
> 
> Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
> ---
> Applies to 3.5.y only (if any distro is still using it).
> ---
>  drivers/staging/comedi/drivers/pcmuio.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
> index 623381d..d49c873 100644
> --- a/drivers/staging/comedi/drivers/pcmuio.c
> +++ b/drivers/staging/comedi/drivers/pcmuio.c
> @@ -914,12 +914,13 @@ static void pcmuio_detach(struct comedi_device *dev)
>  
>  	if (dev->iobase)
>  		release_region(dev->iobase, ASIC_IOSIZE * thisboard->num_asics);
> -	for (i = 0; i < MAX_ASICS; ++i) {
> -		if (devpriv->asics[i].irq)
> -			free_irq(devpriv->asics[i].irq, dev);
> -	}
> -	if (devpriv && devpriv->sprivs)
> +	if (devpriv) {
> +		for (i = 0; i < MAX_ASICS; ++i) {
> +			if (devpriv->asics[i].irq)
> +				free_irq(devpriv->asics[i].irq, dev);
> +		}
>  		kfree(devpriv->sprivs);
> +	}
>  }
>  
>  static const struct pcmuio_board pcmuio_boards[] = {
> -- 
> 1.8.4.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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