From: Cyrill Gorcunov Date: Tue, 6 Jan 2009 22:41:08 +0000 (-0800) Subject: fs: fix name overwrite in __register_chrdev_region() X-Git-Tag: v2.6.29-rc1~365 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=8c4018884a49eb2c6c7ca90804f331b12983561c;p=linux-2.6-omap-h63xx.git fs: fix name overwrite in __register_chrdev_region() It's possible to register a chrdev with a name size exactly the same as was allocated in structure. It seems it was not intended behaviour. At least chrdev_show does not like it. Signed-off-by: Cyrill Gorcunov Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/char_dev.c b/fs/char_dev.c index 700697a7261..38f71222a55 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -120,7 +120,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, cd->major = major; cd->baseminor = baseminor; cd->minorct = minorct; - strncpy(cd->name,name, 64); + strlcpy(cd->name, name, sizeof(cd->name)); i = major_to_index(major);