Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <john@groves.net>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/0100019d8262cda2-9714d31c-8fc1-4ca5-b32d-4df678240d14-000000@email.amazonses.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>

authored by

John Groves and committed by
Ira Weiny
45df9111 2ae624d5

+4 -1
+4 -1
drivers/dax/fsdev.c
··· 80 80 pgoff_t pgoff, size_t nr_pages) 81 81 { 82 82 void *kaddr; 83 + long rc; 83 84 84 85 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; 86 89 fsdev_write_dax(kaddr, ZERO_PAGE(0), 0, PAGE_SIZE); 87 90 return 0; 88 91 }