Skip to content

Commit

Permalink
block: remove the NULL bdev check in bdev_read_only
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jan 25, 2021
1 parent 1e0dcca commit 6f0d968
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 0 additions & 3 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,11 +1657,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);

/*
Expand Down
3 changes: 2 additions & 1 deletion fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6f0d968

Please sign in to comment.