Skip to content

Commit 3b607b7

Browse files
tobluxaxboe
authored andcommitted
null_blk: Use strscpy() instead of strscpy_pad() in null_add_dev()
blk_mq_alloc_disk() already zero-initializes the destination buffer, making strscpy() sufficient for safely copying the disk's name. The additional NUL-padding performed by strscpy_pad() is unnecessary. If the destination buffer has a fixed length, strscpy() automatically determines its size using sizeof() when the argument is omitted. This makes the explicit size argument unnecessary. The source string is also NUL-terminated and meets the __must_be_cstr() requirement of strscpy(). No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20250410154727.883207-1-thorsten.blum@linux.dev Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 818ad0b commit 3b607b7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/null_blk/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ static int null_add_dev(struct nullb_device *dev)
20312031
nullb->disk->minors = 1;
20322032
nullb->disk->fops = &null_ops;
20332033
nullb->disk->private_data = nullb;
2034-
strscpy_pad(nullb->disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
2034+
strscpy(nullb->disk->disk_name, nullb->disk_name);
20352035

20362036
if (nullb->dev->zoned) {
20372037
rv = null_register_zoned_dev(nullb);

0 commit comments

Comments
 (0)