git.openpandora.org
/
pandora-kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[media] ov6650: convert to the control framework
[pandora-kernel.git]
/
lib
/
hexdump.c
diff --git
a/lib/hexdump.c
b/lib/hexdump.c
index
f5fe6ba
..
51d5ae2
100644
(file)
--- a/
lib/hexdump.c
+++ b/
lib/hexdump.c
@@
-38,14
+38,21
@@
EXPORT_SYMBOL(hex_to_bin);
* @dst: binary result
* @src: ascii hexadecimal string
* @count: result length
* @dst: binary result
* @src: ascii hexadecimal string
* @count: result length
+ *
+ * Return 0 on success, -1 in case of bad input.
*/
*/
-
void
hex2bin(u8 *dst, const char *src, size_t count)
+
int
hex2bin(u8 *dst, const char *src, size_t count)
{
while (count--) {
{
while (count--) {
- *dst = hex_to_bin(*src++) << 4;
- *dst += hex_to_bin(*src++);
- dst++;
+ int hi = hex_to_bin(*src++);
+ int lo = hex_to_bin(*src++);
+
+ if ((hi < 0) || (lo < 0))
+ return -1;
+
+ *dst++ = (hi << 4) | lo;
}
}
+ return 0;
}
EXPORT_SYMBOL(hex2bin);
}
EXPORT_SYMBOL(hex2bin);