dax: Ensure errno is returned from dax_direct_access
authorIra Weiny <ira.weiny@intel.com>
Tue, 25 May 2021 17:24:28 +0000 (10:24 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 8 Jul 2021 05:10:04 +0000 (22:10 -0700)
If the caller specifies a negative nr_pages that is an invalid
parameter.

Return -EINVAL to ensure callers get an errno if they want to check it.

Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20210525172428.3634316-4-ira.weiny@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/dax/super.c

index 5fa6ae9dbc8b02b137496231b5f04175f0e5376c..44736cbd446ef747151aa1c807be368a97fbe318 100644 (file)
@@ -313,7 +313,7 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
                return -ENXIO;
 
        if (nr_pages < 0)
-               return nr_pages;
+               return -EINVAL;
 
        avail = dax_dev->ops->direct_access(dax_dev, pgoff, nr_pages,
                        kaddr, pfn);