From: Daniel Scheller Date: Sat, 12 Aug 2017 11:55:55 +0000 (-0400) Subject: media: ddbridge: check pointers before dereferencing X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e89e02a8654f3510114c72394753ab4977b754b3;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Daniel Scheller Tested-by: Richard Scobie Tested-by: Jasmin Jessich Tested-by: Dietmar Spingler Tested-by: Manfred Knick Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index bbd8d556175b..d7bf01f38d98 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -170,10 +170,10 @@ static int ddb_redirect(u32 i, u32 p) struct ddb *pdev = ddbs[(p >> 4) & 0x3f]; struct ddb_port *port; - if (!idev->has_dma || !pdev->has_dma) - return -EINVAL; if (!idev || !pdev) return -EINVAL; + if (!idev->has_dma || !pdev->has_dma) + return -EINVAL; port = &pdev->port[p & 0x0f]; if (!port->output)