From: manish.narani@xilinx.com (Manish Narani)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/4] iio: adc: xilinx: Check for return values in clk related functions
Date: Mon, 23 Jul 2018 20:32:00 +0530 [thread overview]
Message-ID: <1532358123-23485-2-git-send-email-manish.narani@xilinx.com> (raw)
In-Reply-To: <1532358123-23485-1-git-send-email-manish.narani@xilinx.com>
This patch adds check for return values from clock related functions.
This was reported by static code analysis tool.
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
drivers/iio/adc/xilinx-xadc-core.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 0127e85..23395fc 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -340,6 +340,8 @@ static int xadc_zynq_setup(struct platform_device *pdev,
xadc->zynq_intmask = ~0;
pcap_rate = clk_get_rate(xadc->clk);
+ if (!pcap_rate)
+ return -EINVAL;
if (tck_rate > pcap_rate / 2) {
div = 2;
@@ -887,6 +889,9 @@ static int xadc_write_raw(struct iio_dev *indio_dev,
unsigned long clk_rate = xadc_get_dclk_rate(xadc);
unsigned int div;
+ if (!clk_rate)
+ return -EINVAL;
+
if (info != IIO_CHAN_INFO_SAMP_FREQ)
return -EINVAL;
@@ -1237,8 +1242,10 @@ static int xadc_probe(struct platform_device *pdev)
goto err_free_irq;
/* Disable all alarms */
- xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK,
- XADC_CONF1_ALARM_MASK);
+ ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK,
+ XADC_CONF1_ALARM_MASK);
+ if (ret)
+ goto err_free_irq;
/* Set thresholds to min/max */
for (i = 0; i < 16; i++) {
--
2.1.1
next prev parent reply other threads:[~2018-07-23 15:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 15:01 [PATCH v2 0/4] iio: adc: xilinx: XADC driver Enhancements and bug fixes Manish Narani
2018-07-23 15:02 ` Manish Narani [this message]
2018-07-29 11:48 ` [PATCH v2 1/4] iio: adc: xilinx: Check for return values in clk related functions Jonathan Cameron
2018-07-23 15:02 ` [PATCH v2 2/4] iio: adc: xilinx: limit pcap clock frequency value Manish Narani
2018-07-29 11:51 ` Jonathan Cameron
2018-07-30 10:13 ` Manish Narani
2018-07-23 15:02 ` [PATCH v2 3/4] iio: adc: xilinx: Remove platform_get_irq from xadc_remove function Manish Narani
2018-07-29 12:29 ` Jonathan Cameron
2018-07-23 15:02 ` [PATCH v2 4/4] iio: adc: xilinx: Move request_irq before enabling interrupts Manish Narani
2018-07-29 12:30 ` Jonathan Cameron
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=1532358123-23485-2-git-send-email-manish.narani@xilinx.com \
--to=manish.narani@xilinx.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).