[PATCH] drivers: mfd: fix off by one error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



snprintf() is overflowed iff result is greater or equal than
argument "size".

Signed-off-by: Vasiliy Kulikov <segooon@xxxxxxxxx>
---
 Compile tested.

 drivers/mfd/mc13xxx-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 93258ad..cd4d670 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -696,7 +696,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
 	};
 
 	/* there is no asnprintf in the kernel :-( */
-	if (snprintf(buf, sizeof(buf), format, name) > sizeof(buf))
+	if (snprintf(buf, sizeof(buf), format, name) >= sizeof(buf))
 		return -E2BIG;
 
 	cell.name = kmemdup(buf, strlen(buf) + 1, GFP_KERNEL);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux