]> www.infradead.org Git - users/hch/block.git/commitdiff
block: remove the NULL bdev check in bdev_read_only
authorChristoph Hellwig <hch@lst.de>
Sat, 5 Dec 2020 09:09:41 +0000 (10:09 +0100)
committerChristoph Hellwig <hch@lst.de>
Sat, 9 Jan 2021 09:13:08 +0000 (10:13 +0100)
Only a single caller can end up in bdev_read_only, so move the check
there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
block/genhd.c
fs/super.c

index 73faec438e49a88d308bb438c9e170dcacdc986e..4f90f80d7aa76d32a01cd0f8174ac3420bc9006b 100644 (file)
@@ -1654,11 +1654,8 @@ EXPORT_SYMBOL(set_disk_ro);
 
 int bdev_read_only(struct block_device *bdev)
 {
-       if (!bdev)
-               return 0;
        return bdev->bd_read_only;
 }
-
 EXPORT_SYMBOL(bdev_read_only);
 
 /*
index 2c6cdea2ab2d9ed76bb07501d8a53f7dd827d56d..5a1f384ffc74f6f99ec0dbdef95be75ed94a9164 100644 (file)
@@ -865,7 +865,8 @@ int reconfigure_super(struct fs_context *fc)
 
        if (fc->sb_flags_mask & SB_RDONLY) {
 #ifdef CONFIG_BLOCK
-               if (!(fc->sb_flags & SB_RDONLY) && bdev_read_only(sb->s_bdev))
+               if (!(fc->sb_flags & SB_RDONLY) && sb->s_bdev &&
+                   bdev_read_only(sb->s_bdev))
                        return -EACCES;
 #endif