Commit e89e02a8 authored by Daniel Scheller's avatar Daniel Scheller Committed by Mauro Carvalho Chehab

media: ddbridge: check pointers before dereferencing

Fixes two warnings reported by smatch:

  drivers/media/pci/ddbridge/ddbridge-core.c:240 ddb_redirect() warn: variable dereferenced before check 'idev' (see line 238)
  drivers/media/pci/ddbridge/ddbridge-core.c:240 ddb_redirect() warn: variable dereferenced before check 'pdev' (see line 238)

Fixed by moving the existing checks up before accessing members.

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: default avatarDaniel Scheller <d.scheller@gmx.net>
Tested-by: default avatarRichard Scobie <r.scobie@clear.net.nz>
Tested-by: default avatarJasmin Jessich <jasmin@anw.at>
Tested-by: default avatarDietmar Spingler <d_spingler@freenet.de>
Tested-by: default avatarManfred Knick <Manfred.Knick@t-online.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 69716934
...@@ -170,10 +170,10 @@ static int ddb_redirect(u32 i, u32 p) ...@@ -170,10 +170,10 @@ static int ddb_redirect(u32 i, u32 p)
struct ddb *pdev = ddbs[(p >> 4) & 0x3f]; struct ddb *pdev = ddbs[(p >> 4) & 0x3f];
struct ddb_port *port; struct ddb_port *port;
if (!idev->has_dma || !pdev->has_dma)
return -EINVAL;
if (!idev || !pdev) if (!idev || !pdev)
return -EINVAL; return -EINVAL;
if (!idev->has_dma || !pdev->has_dma)
return -EINVAL;
port = &pdev->port[p & 0x0f]; port = &pdev->port[p & 0x0f];
if (!port->output) if (!port->output)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment