Skip to content

Commit 45df911

Browse files
jagalacticweiny2
authored andcommitted
dax/fsdev: fix uninitialized kaddr in fsdev_dax_zero_page_range()
__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. Signed-off-by: John Groves <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Link: https://patch.msgid.link/0100019d8262cda2-9714d31c-8fc1-4ca5-b32d-4df678240d14-000000@email.amazonses.com Signed-off-by: Ira Weiny <[email protected]>
1 parent 2ae624d commit 45df911

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/dax/fsdev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ static int fsdev_dax_zero_page_range(struct dax_device *dax_dev,
8080
pgoff_t pgoff, size_t nr_pages)
8181
{
8282
void *kaddr;
83+
long rc;
8384

8485
WARN_ONCE(nr_pages > 1, "%s: nr_pages > 1\n", __func__);
85-
__fsdev_dax_direct_access(dax_dev, pgoff, 1, DAX_ACCESS, &kaddr, NULL);
86+
rc = __fsdev_dax_direct_access(dax_dev, pgoff, 1, DAX_ACCESS, &kaddr, NULL);
87+
if (rc < 0)
88+
return rc;
8689
fsdev_write_dax(kaddr, ZERO_PAGE(0), 0, PAGE_SIZE);
8790
return 0;
8891
}

0 commit comments

Comments
 (0)