@@ -52,7 +52,8 @@ EXPORT_SYMBOL_GPL(dax_read_unlock);
int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
pgoff_t *pgoff)
{
- phys_addr_t phys_off = (get_start_sect(bdev) + sector) * 512;
+ sector_t start_sect = bdev ? get_start_sect(bdev) : 0;
+ phys_addr_t phys_off = (start_sect + sector) * 512;
if (pgoff)
*pgoff = PHYS_PFN(phys_off);
@@ -1021,7 +1021,12 @@ static vm_fault_t dax_load_hole(struct xa_state *xas,
static bool dax_range_is_aligned(struct block_device *bdev,
unsigned int offset, unsigned int length)
{
- unsigned short sector_size = bdev_logical_block_size(bdev);
+ unsigned short sector_size;
+
+ if (!bdev)
+ return false;
+
+ sector_size = bdev_logical_block_size(bdev);
if (!IS_ALIGNED(offset, sector_size))
return false;