From: Mathieu Malaterre <malat@debian.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Mathieu Malaterre <malat@debian.org>, linux-kernel@vger.kernel.org
Subject: [PATCH] nvmem: properly handle returned value nvmem_reg_read
Date: Sat, 5 May 2018 22:24:50 +0200 [thread overview]
Message-ID: <20180505202450.26630-1-malat@debian.org> (raw)
Function nvmem_reg_read can return a non zero value indicating an error.
This returned value must be read and error propagated to
nvmem_cell_prepare_write_buffer. Silence the following gcc warning (W=1):
drivers/nvmem/core.c:1093:9: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
drivers/nvmem/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index b05aa8e81303..f34f2363925a 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1107,6 +1107,8 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
/* setup the first byte with lsb bits from nvmem */
rc = nvmem_reg_read(nvmem, cell->offset, &v, 1);
+ if (rc)
+ goto err;
*b++ |= GENMASK(bit_offset - 1, 0) & v;
/* setup rest of the byte if any */
@@ -1125,11 +1127,16 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
/* setup the last byte with msb bits from nvmem */
rc = nvmem_reg_read(nvmem,
cell->offset + cell->bytes - 1, &v, 1);
+ if (rc)
+ goto err;
*p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;
}
return buf;
+err:
+ kfree(buf);
+ return NULL;
}
/**
--
2.11.0
next reply other threads:[~2018-05-05 20:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-05 20:24 Mathieu Malaterre [this message]
2018-05-06 13:58 ` [PATCH] nvmem: properly handle returned value nvmem_reg_read Andy Shevchenko
2018-05-08 9:30 ` Srinivas Kandagatla
2018-05-09 18:57 ` [PATCH v2] " Mathieu Malaterre
2018-05-10 9:58 ` Srinivas Kandagatla
2018-05-10 18:40 ` Mathieu Malaterre
2018-05-10 18:39 ` [PATCH v3] nvmem: properly handle returned value from nvmem_reg_read Mathieu Malaterre
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=20180505202450.26630-1-malat@debian.org \
--to=malat@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.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).