From: trix@redhat.com
To: jasmin@anw.at, mchehab@kernel.org, o.endriss@gmx.de, rjkm@metzlerbros.de
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Tom Rix <trix@redhat.com>
Subject: [PATCH] media: dvb-frontends/cxd2099: report errors
Date: Wed, 22 Jul 2020 06:41:26 -0700 [thread overview]
Message-ID: <20200722134126.31191-1-trix@redhat.com> (raw)
From: Tom Rix <trix@redhat.com>
Clang static analysis reports this error
drivers/media/dvb-frontends/cxd2099.c:420:2: warning: Undefined
or garbage value returned to caller
return val;
^~~~~~~~~~
In read_cam_control, the call to read_io can fail.
When it fails val is not set.
The failure status should be returned to the caller,
not the unset val.
Similar problem with read_attribute_mem
Fixes: 0f0b270f905b ("[media] ngene: CXD2099AR Common Interface driver")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/media/dvb-frontends/cxd2099.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/media/dvb-frontends/cxd2099.c b/drivers/media/dvb-frontends/cxd2099.c
index f88b5355493e..9dfaf18fc4b4 100644
--- a/drivers/media/dvb-frontends/cxd2099.c
+++ b/drivers/media/dvb-frontends/cxd2099.c
@@ -387,12 +387,15 @@ static int read_attribute_mem(struct dvb_ca_en50221 *ca,
{
struct cxd *ci = ca->data;
u8 val;
+ int ret;
mutex_lock(&ci->lock);
set_mode(ci, 1);
- read_pccard(ci, address, &val, 1);
+ ret = read_pccard(ci, address, &val, 1);
+ if (!ret)
+ ret = val;
mutex_unlock(&ci->lock);
- return val;
+ return ret;
}
static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot,
@@ -412,12 +415,15 @@ static int read_cam_control(struct dvb_ca_en50221 *ca,
{
struct cxd *ci = ca->data;
unsigned int val;
+ int ret;
mutex_lock(&ci->lock);
set_mode(ci, 0);
- read_io(ci, address, &val);
+ ret = read_io(ci, address, &val);
+ if (!ret)
+ ret = val;
mutex_unlock(&ci->lock);
- return val;
+ return ret;
}
static int write_cam_control(struct dvb_ca_en50221 *ca, int slot,
--
2.18.1
next reply other threads:[~2020-07-22 13:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 13:41 trix [this message]
2020-09-03 14:13 ` [PATCH] media: dvb-frontends/cxd2099: report errors Mauro Carvalho Chehab
2020-09-03 14:41 ` Tom Rix
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=20200722134126.31191-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=jasmin@anw.at \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=o.endriss@gmx.de \
--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).