From: Daniel Scheller <d.scheller.oss@gmail.com>
To: linux-media@vger.kernel.org, mchehab@kernel.org,
mchehab@s-opensource.com
Cc: jasmin@anw.at, d_spingler@gmx.de, rjkm@metzlerbros.de
Subject: [PATCH 12/14] [media] ddbridge: fix dereference before check
Date: Sun, 9 Jul 2017 21:42:19 +0200 [thread overview]
Message-ID: <20170709194221.10255-13-d.scheller.oss@gmail.com> (raw)
In-Reply-To: <20170709194221.10255-1-d.scheller.oss@gmail.com>
From: Daniel Scheller <d.scheller@gmx.net>
Both ts_release() and ts_open() can use "output" before check (smatch):
drivers/media/pci/ddbridge/ddbridge-core.c:816 ts_release() warn: variable dereferenced before check 'output' (see line 809)
drivers/media/pci/ddbridge/ddbridge-core.c:836 ts_open() warn: variable dereferenced before check 'output' (see line 828)
Fix by performing checks on those pointers.
Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
---
drivers/media/pci/ddbridge/ddbridge-core.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 6896cd1f3a96..ff87e0462c7e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -738,8 +738,13 @@ static unsigned int ts_poll(struct file *file, poll_table *wait)
static int ts_release(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
- struct ddb_output *output = dvbdev->priv;
- struct ddb_input *input = output->port->input[0];
+ struct ddb_output *output = NULL;
+ struct ddb_input *input = NULL;
+
+ if (dvbdev) {
+ output = dvbdev->priv;
+ input = output->port->input[0];
+ }
if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (!input)
@@ -757,8 +762,13 @@ static int ts_open(struct inode *inode, struct file *file)
{
int err;
struct dvb_device *dvbdev = file->private_data;
- struct ddb_output *output = dvbdev->priv;
- struct ddb_input *input = output->port->input[0];
+ struct ddb_output *output = NULL;
+ struct ddb_input *input = NULL;
+
+ if (dvbdev) {
+ output = dvbdev->priv;
+ input = output->port->input[0];
+ }
if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (!input)
--
2.13.0
next prev parent reply other threads:[~2017-07-09 19:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-09 19:42 [PATCH 00/14] ddbridge: bump to ddbridge-0.9.29 Daniel Scheller
2017-07-09 19:42 ` [PATCH 01/14] [media] ddbridge: move/reorder functions Daniel Scheller
2017-07-09 19:42 ` [PATCH 02/14] [media] ddbridge: split code into multiple files Daniel Scheller
2017-07-09 19:42 ` [PATCH 03/14] [media] ddbridge: bump ddbridge code to version 0.9.29 Daniel Scheller
2017-07-09 19:42 ` [PATCH 04/14] [media] ddbridge: split I/O related functions off from ddbridge.h Daniel Scheller
2017-07-09 19:42 ` [PATCH 05/14] [media] ddbridge: split off IRQ handling Daniel Scheller
2017-07-09 19:42 ` [PATCH 06/14] [media] ddbridge: split off hardware definitions and mappings Daniel Scheller
2017-07-09 19:42 ` [PATCH 07/14] [media] ddbridge: check pointers before dereferencing Daniel Scheller
2017-07-09 19:42 ` [PATCH 08/14] [media] ddbridge: only register frontends in fe2 if fe is not NULL Daniel Scheller
2017-07-09 19:42 ` [PATCH 09/14] [media] ddbridge: fix possible buffer overflow in ddb_ports_init() Daniel Scheller
2017-07-10 8:21 ` Ralph Metzler
2017-07-10 15:32 ` Daniel Scheller
2017-07-09 19:42 ` [PATCH 10/14] [media] ddbridge: remove unreachable code Daniel Scheller
2017-07-10 8:24 ` Ralph Metzler
2017-07-10 15:34 ` Daniel Scheller
2017-07-09 19:42 ` [PATCH 11/14] [media] ddbridge: fix impossible condition warning Daniel Scheller
2017-07-09 19:42 ` Daniel Scheller [this message]
2017-07-09 19:42 ` [PATCH 13/14] [media] ddbridge: Kconfig option to control the MSI modparam default Daniel Scheller
2017-07-09 19:42 ` [PATCH 14/14] [media] MAINTAINERS: add entry for ddbridge Daniel Scheller
2017-07-10 8:11 ` [PATCH 00/14] ddbridge: bump to ddbridge-0.9.29 Ralph Metzler
2017-07-10 15:31 ` Daniel Scheller
2017-07-11 9:11 ` Ralph Metzler
2017-07-11 15:30 ` Daniel Scheller
2017-07-20 15:24 ` Mauro Carvalho Chehab
2017-07-20 18:25 ` Daniel Scheller
2017-07-20 21:16 ` Jasmin J.
2017-07-15 20:37 ` Richard Scobie
2017-07-23 12:16 ` Daniel Scheller
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=20170709194221.10255-13-d.scheller.oss@gmail.com \
--to=d.scheller.oss@gmail.com \
--cc=d_spingler@gmx.de \
--cc=jasmin@anw.at \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mchehab@s-opensource.com \
--cc=rjkm@metzlerbros.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).