Skip to content

Commit

Permalink
[media] [Resend] viacam: Don't explode if pci_find_bus() returns NULL
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jonathan Corbet <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
jjuhl authored and Mauro Carvalho Chehab committed Sep 11, 2011
1 parent 6a02a33 commit c8814df
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/media/video/via-camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c8814df

Please sign in to comment.