From: Kangjie Lu <kjlu@umn.edu>
To: kjlu@umn.edu
Cc: pakki001@umn.edu, Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Samuel Holland <samuel@sholland.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] firmware: (memconsole) do not count numbers if read fails
Date: Tue, 25 Dec 2018 23:29:11 -0600 [thread overview]
Message-ID: <20181226052913.74614-1-kjlu@umn.edu> (raw)
When memory_read_from_buffer() fails, the return value is a negative
error code, thus we shouldn't count it as the number of read bytes.
The fix checks the return value of memory_read_from_buffer, and count
the number only when it succeeds.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/firmware/google/memconsole-coreboot.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/google/memconsole-coreboot.c b/drivers/firmware/google/memconsole-coreboot.c
index b29e10757bfb..4e8a0ad110c1 100644
--- a/drivers/firmware/google/memconsole-coreboot.c
+++ b/drivers/firmware/google/memconsole-coreboot.c
@@ -55,6 +55,7 @@ static ssize_t memconsole_coreboot_read(char *buf, loff_t pos, size_t count)
} seg[2] = { {0}, {0} };
size_t done = 0;
int i;
+ int ret;
if (flags & OVERFLOW) {
if (cursor > size) /* Shouldn't really happen, but... */
@@ -66,8 +67,10 @@ static ssize_t memconsole_coreboot_read(char *buf, loff_t pos, size_t count)
}
for (i = 0; i < ARRAY_SIZE(seg) && count > done; i++) {
- done += memory_read_from_buffer(buf + done, count - done, &pos,
+ ret = memory_read_from_buffer(buf + done, count - done, &pos,
cbmem_console->body + seg[i].phys, seg[i].len);
+ if (ret >= 0)
+ done += ret;
pos -= seg[i].len;
}
return done;
--
2.17.2 (Apple Git-113)
next reply other threads:[~2018-12-26 5:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 5:29 Kangjie Lu [this message]
2019-01-22 9:27 ` Greg Kroah-Hartman
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=20181226052913.74614-1-kjlu@umn.edu \
--to=kjlu@umn.edu \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pakki001@umn.edu \
--cc=samuel@sholland.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®