Currently the 'c2dev' device data is not initialised when it's
allocated.  There maybe an issue when using strncpy() to populate the
'name' attribute since a NUL terminator may not be provided in all
use-cases.  To prevent such a failing, let's ensure the 'c2dev'
device data area is fully zeroed out on allocation.

Cc: Rodolfo Giometti <giome...@enneenne.com>
Cc: "Eurotech S.p.A" <i...@eurotech.it>
Cc: David Laight <david.lai...@aculab.com>
Reported-by: Geert Uytterhoeven <geert+rene...@glider.be>
Acked-by: Arnd Bergmann <a...@arndb.de>
Signed-off-by: Lee Jones <lee.jo...@linaro.org>
---
 drivers/misc/c2port/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index 80d87e8a0bea9..fb9a1b49ff6de 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -899,7 +899,7 @@ struct c2port_device *c2port_device_register(char *name,
                unlikely(!ops->c2d_get) || unlikely(!ops->c2d_set))
                return ERR_PTR(-EINVAL);
 
-       c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL);
+       c2dev = kzalloc(sizeof(struct c2port_device), GFP_KERNEL);
        if (unlikely(!c2dev))
                return ERR_PTR(-ENOMEM);
 
-- 
2.25.1

Reply via email to