From: vbyravarasu@nvidia.com
To: linux-kernel@vger.kernel.org
Cc: venu byravarasu <vbyravarasu@nvidia.com>
Subject: [PATCH] bcd: limit bin2bcd input value to lie between 0-99
Date: Tue, 15 Nov 2011 18:10:39 +0530 [thread overview]
Message-ID: <1321360839-26451-1-git-send-email-vbyravarasu@nvidia.com> (raw)
From: venu byravarasu <vbyravarasu@nvidia.com>
If bin2bcd gets a value which is more than 100,
there are chances that it may store non decimal
value in the most significant nibble.
e.g. say val passed to bin2bcd is 112.
In that case the expected value to be returned by
this function is 12.
However, without the fix being added it would
be 112.
Signed-off-by: venu byravarasu <vbyravarasu@nvidia.com>
---
lib/bcd.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/lib/bcd.c b/lib/bcd.c
index d74257f..d715474 100644
--- a/lib/bcd.c
+++ b/lib/bcd.c
@@ -9,6 +9,7 @@ EXPORT_SYMBOL(bcd2bin);
unsigned char bin2bcd(unsigned val)
{
+ val %= 100;
return ((val / 10) << 4) + val % 10;
}
EXPORT_SYMBOL(bin2bcd);
--
1.7.1.1
next reply other threads:[~2011-11-15 12:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 12:40 vbyravarasu [this message]
2011-11-16 5:11 vbyravarasu
2011-11-22 22:32 ` Andrew Morton
2011-11-23 3:52 ` Venu Byravarasu
2011-12-13 9:56 ` Venu Byravarasu
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=1321360839-26451-1-git-send-email-vbyravarasu@nvidia.com \
--to=vbyravarasu@nvidia.com \
--cc=linux-kernel@vger.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®