All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Kosina <jkosina@suse.cz>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH][Resend] viacam: Don't explode if pci_find_bus() returns NULL
Date: Thu, 15 Sep 2011 14:59:03 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1109151458550.13109@pobox.suse.cz> (raw)
In-Reply-To: <alpine.LNX.2.00.1108012337070.31999@swampdragon.chaosbits.net>

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@chaosbits.net>
> Acked-by: Jonathan Corbet <corbet@lwn.net>
> ---
>  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

      reply	other threads:[~2011-09-15 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 21:39 [PATCH][Resend] viacam: Don't explode if pci_find_bus() returns NULL Jesper Juhl
2011-09-15 12:59 ` Jiri Kosina [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1109151458550.13109@pobox.suse.cz \
    --to=jkosina@suse.cz \
    --cc=corbet@lwn.net \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.