We use strlcpy() to copy device name in register_blkdev(), so if the device name is longer enough(accurately longer than 15 bytes), the copied name is truncated to 15 bytes. In this case, it's better to use strncmp() to compare device name instead of strcmp() in unregister_blkdev(), so that we can recognize the device name correctly. Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx> --- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/genhd.c b/block/genhd.c index 1dd8fd6613b8..efc532ae9de9 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -424,7 +424,7 @@ void unregister_blkdev(unsigned int major, const char *name) for (n = &major_names[index]; *n; n = &(*n)->next) if ((*n)->major == major) break; - if (!*n || strcmp((*n)->name, name)) { + if (!*n || strncmp((*n)->name, name, strlen((*n)->name))) { WARN_ON(1); } else { p = *n; -- 2.20.1