Skip to content

Commit 8c40188

Browse files
cyrillostorvalds
authored andcommitted
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 <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ba84be2 commit 8c40188

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/char_dev.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
120120
cd->major = major;
121121
cd->baseminor = baseminor;
122122
cd->minorct = minorct;
123-
strncpy(cd->name,name, 64);
123+
strlcpy(cd->name, name, sizeof(cd->name));
124124

125125
i = major_to_index(major);
126126

0 commit comments

Comments
 (0)