dax: Add direct_access() callback check for dax_direct_access()
Dave Jiang
maintainerPATCH 1/1 dax: Add direct_access() callback check for dax_direct_access()
__devm_create_dev_dax() calls alloc_dax() with the ops parameter passed in as NULL. Therefore the ops pointer in dev_dax can be NULL. Add a check in dax_direct_access() for ops and ops->direct_access() before calling ops->direct_access().
Signed-off-by Dave Jiang <[email protected]>
--- drivers/dax/super.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dax/super.c +3 -0
@@ -160,6 +160,9 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,if (nr_pages <0 )return -EINVAL ; +if (!dax_dev->ops || !dax_dev->ops->direct_access) +return -EOPNOTSUPP ; + avail = dax_dev->ops->direct_access (dax_dev, pgoff, nr_pages, mode, kaddr, pfn);if (!avail)
base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
Signature · 1 line
2.53.0
Quoted 4 lines · Dave Jiang
__devm_create_dev_dax()callsalloc_dax()with the ops parameter passed in as NULL. Therefore the ops pointer indev_daxcan be NULL. Add a check indax_direct_access()for ops andops->direct_access()before callingops->direct_access().
Doesn't this need checking in dax_zero_page_range() and dax_recovery_write() as well?
Ira
Quoted 26 lines
Signed-off-by Dave Jiang <[email protected]>--- drivers/dax/super.c | 3 +++ 1 file changed, 3 insertions(+)drivers/dax/super.c +3
-0@@ -160,6 +160,9 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,if (nr_pages <0 )return -EINVAL ; +if (!dax_dev->ops || !dax_dev->ops->direct_access) +return -EOPNOTSUPP ; + avail = dax_dev->ops->direct_access (dax_dev, pgoff, nr_pages, mode, kaddr, pfn);if (!avail)base-commit:
11439c4635edd669ae435eec308f4ab8a0804808Signature · 1 line
2.53.0