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

From: Vasiliy Kulikov
Date: Sun Oct 10 2010 - 13:28:43 EST


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 linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/