From: Baruch Siach <baruch@tkos.co.il>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] radio: wl1273: add check on core->write() return value
Date: Thu, 22 Jun 2017 07:50:34 +0300 [thread overview]
Message-ID: <20170622045034.tkyksrbdm353xmdu@tarshish> (raw)
In-Reply-To: <20170622040122.GA7161@embeddedgus>
Hi Gustavi,
On Wed, Jun 21, 2017 at 11:01:22PM -0500, Gustavo A. R. Silva wrote:
> Check return value from call to core->write(), so in case of
> error print error message, jump to goto label fail and eventually
> return.
>
> Addresses-Coverity-ID: 1226943
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> drivers/media/radio/radio-wl1273.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
> index 7240223..17e82a9 100644
> --- a/drivers/media/radio/radio-wl1273.c
> +++ b/drivers/media/radio/radio-wl1273.c
> @@ -610,10 +610,21 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
> }
> }
>
> - if (radio->rds_on)
> + if (radio->rds_on) {
> r = core->write(core, WL1273_RDS_DATA_ENB, 1);
> - else
> + if (r) {
> + dev_err(dev, "%s: RDS_DATA_ENB ON fails\n",
> + __func__);
> + goto fail;
> + }
> + } else {
> r = core->write(core, WL1273_RDS_DATA_ENB, 0);
> + if (r) {
> + dev_err(dev, "%s: RDS_DATA_ENB OFF fails\n",
> + __func__);
> + goto fail;
> + }
> + }
> } else {
> dev_warn(dev, "%s: Illegal mode.\n", __func__);
> }
An alternative that duplicates less code (untested):
r = core->write(core, WL1273_RDS_DATA_ENB, !!radio->rds_on);
if (r) {
dev_err(dev, "%s: RDS_DATA_ENB %s fails\n",
__func__, radio->rds_on ? "ON" : "OFF");
goto fail;
}
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
prev parent reply other threads:[~2017-06-22 4:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 4:01 Gustavo A. R. Silva
2017-06-22 4:50 ` Baruch Siach [this message]
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=20170622045034.tkyksrbdm353xmdu@tarshish \
--to=baruch@tkos.co.il \
--cc=garsilva@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/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
all inboxes | Powered by JetHome®