dax/fsdev: fix uninitialized kaddr in fsdev_dax_zero_page_range()
Subsystems (3)
PATCH 1/1 dax/fsdev: fix uninitialized kaddr in fsdev_dax_zero_page_range()
In reply to a message not in the archiveFrom: John Groves <[email protected]>
__fsdev_dax_direct_access() returns -EFAULT without setting *kaddr when dax_pgoff_to_phys() returns -1 (pgoff out of range). The return value was ignored, leaving kaddr uninitialized before being passed to fsdev_write_dax().
Check the return value and propagate the error.
Thanks to Dan Carpenter and the smatch project for reporting this.
--- drivers/dax/fsdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dax/fsdev.c +4 -1
@@ -80,9 +80,12 @@ static int fsdev_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, size_t nr_pages) { void *kaddr; +long rc;WARN_ONCE (nr_pages >1 ,"%s: nr_pages > 1\n" , __func__); -__fsdev_dax_direct_access (dax_dev, pgoff,1 ,DAX_ACCESS , &kaddr,NULL ); + rc =__fsdev_dax_direct_access (dax_dev, pgoff,1 ,DAX_ACCESS , &kaddr,NULL ); +if (rc <0 ) +return rc;fsdev_write_dax (kaddr,ZERO_PAGE (0 ),0 ,PAGE_SIZE );return 0 ; }
base-commit: 2ae624d5a555d47a735fb3f4d850402859a4db77
Signature · 1 line
2.53.0
Quoted 7 lines · On Sun, 12 Apr 2026 15:50:06 +0000 John Groves <[email protected]> wrote:
From: John Groves <[email protected]>
__fsdev_dax_direct_access()returns-EFAULTwithout setting *kaddr whendax_pgoff_to_phys()returns -1 (pgoff out of range). The return value was ignored, leaving kaddr uninitialized before being passed tofsdev_write_dax().
Quoted 5 lines
Check the return value and propagate the error.
Thanks to Dan Carpenter and the smatch project for reporting this.
Signed-off-by John Groves <[email protected]>
Quoted 7 lines · John Groves
From: John Groves <[email protected]>
__fsdev_dax_direct_access()returns-EFAULTwithout setting *kaddr whendax_pgoff_to_phys()returns -1 (pgoff out of range). The return value was ignored, leaving kaddr uninitialized before being passed tofsdev_write_dax().
Quoted 5 lines
Check the return value and propagate the error.
Thanks to Dan Carpenter and the smatch project for reporting this.
Signed-off-by John Groves <[email protected]>
Quoted 24 lines
--- drivers/dax/fsdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/dax/fsdev.c +4
-1@@ -80,9 +80,12 @@ static int fsdev_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, size_t nr_pages) { void *kaddr; +long rc;WARN_ONCE (nr_pages >1 ,"%s: nr_pages > 1\n" , __func__); -__fsdev_dax_direct_access (dax_dev, pgoff,1 ,DAX_ACCESS , &kaddr,NULL ); + rc =__fsdev_dax_direct_access (dax_dev, pgoff,1 ,DAX_ACCESS , &kaddr,NULL ); +if (rc <0 ) +return rc;fsdev_write_dax (kaddr,ZERO_PAGE (0 ),0 ,PAGE_SIZE );return 0 ; }base-commit:
2ae624d5a555d47a735fb3f4d850402859a4db77