Re: [PATCH][Resend] viacam: Don't explode if pci_find_bus() returnsNULL

From: Jiri Kosina
Date: Thu Sep 15 2011 - 08:59:10 EST


On Mon, 1 Aug 2011, Jesper Juhl wrote:

> In the unlikely case that pci_find_bus() should return NULL
> viacam_serial_is_enabled() is going to dereference a NULL pointer and
> blow up. Better safe than sorry, so be defensive and check the
> pointer.
>
> Signed-off-by: Jesper Juhl <jj@xxxxxxxxxxxxx>
> Acked-by: Jonathan Corbet <corbet@xxxxxxx>
> ---
> drivers/media/video/via-camera.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/media/video/via-camera.c b/drivers/media/video/via-camera.c
> index 85d3048..bb7f17f 100644
> --- a/drivers/media/video/via-camera.c
> +++ b/drivers/media/video/via-camera.c
> @@ -1332,6 +1332,8 @@ static __devinit bool viacam_serial_is_enabled(void)
> struct pci_bus *pbus = pci_find_bus(0, 0);
> u8 cbyte;
>
> + if (!pbus)
> + return false;
> pci_bus_read_config_byte(pbus, VIACAM_SERIAL_DEVFN,
> VIACAM_SERIAL_CREG, &cbyte);
> if ((cbyte & VIACAM_SERIAL_BIT) == 0)

Applied, thanks.

--
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/