diff --git a/lib/hexdump.c b/lib/hexdump.c index 81b70ed37209697c083247264c9374b143c1749f..69e4b0fdf5e8e8fa899d6254827acea12d9a61fd 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -48,10 +48,13 @@ EXPORT_SYMBOL(hex_to_bin); int hex2bin(u8 *dst, const char *src, size_t count) { while (count--) { - int hi = hex_to_bin(*src++); - int lo = hex_to_bin(*src++); + int hi, lo; - if ((hi < 0) || (lo < 0)) + hi = hex_to_bin(*src++); + if (unlikely(hi < 0)) + return -EINVAL; + lo = hex_to_bin(*src++); + if (unlikely(lo < 0)) return -EINVAL; *dst++ = (hi << 4) | lo;