]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
null_blk: Constify struct configfs_item_operations and configfs_group_operations
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 29 Dec 2025 10:26:07 +0000 (11:26 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 29 Dec 2025 15:19:15 +0000 (08:19 -0700)
'struct configfs_item_operations' and 'configfs_group_operations' are not
modified in this driver.

Constifying these structures moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
 100263   37808    2752  140823   22617 drivers/block/null_blk/main.o

After:
=====
   text    data     bss     dec     hex filename
 100423   37648    2752  140823   22617 drivers/block/null_blk/main.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/null_blk/main.c

index c7c0fb79a6bf6b695966e5a011441fbd3c93abe5..29a371f48b5781bca01d25821b0b84b4cbcf7e25 100644 (file)
@@ -642,7 +642,7 @@ static void nullb_device_release(struct config_item *item)
        null_free_dev(dev);
 }
 
-static struct configfs_item_operations nullb_device_ops = {
+static const struct configfs_item_operations nullb_device_ops = {
        .release        = nullb_device_release,
 };
 
@@ -739,7 +739,7 @@ static struct configfs_attribute *nullb_group_attrs[] = {
        NULL,
 };
 
-static struct configfs_group_operations nullb_group_ops = {
+static const struct configfs_group_operations nullb_group_ops = {
        .make_group     = nullb_group_make_group,
        .drop_item      = nullb_group_drop_item,
 };