Skip to contentSkip to conversation

dax: check return value of dax_radix_entry()

PATCH In review Ross Zwisler 2 participants 3 messages Mar 2, 2016 – Mar 3, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dax: check return value of dax_radix_entry()

dax_pfn_mkwrite() previously wasn't checking the return value of the call to dax_radix_entry(), which was a mistake.

Instead, capture this return value and return the appropriate VM_FAULT_ value.

---
 fs/dax.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/dax.c +8 -1
index 7111724..bbb2ad7 100644
@@ -1056,6 +1056,7 @@ EXPORT_SYMBOL_GPL(dax_pmd_fault);
 int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct file *file = vma->vm_file;
+	int error;
 
 	/*
 	 * We pass NO_SECTOR to dax_radix_entry() because we expect that a
@@ -1065,7 +1066,13 @@ int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 	 * saves us from having to make a call to get_block() here to look
 	 * up the sector.
 	 */
-	dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false, true);
+	error = dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false,
+			true);
+
+	if (error == -ENOMEM)
+		return VM_FAULT_OOM;
+	if (error)
+		return VM_FAULT_SIGBUS;
 	return VM_FAULT_NOPAGE;
 }
 EXPORT_SYMBOL_GPL(dax_pfn_mkwrite);
Signature · 1 line
2.5.0
#1 lore raw
Quoted 7 lines · Ross Zwisler

dax_pfn_mkwrite() previously wasn't checking the return value of the call to dax_radix_entry(), which was a mistake.

Instead, capture this return value and return the appropriate VM_FAULT_ value.

Hi Ross,

Can you please cc dax stuff to linux-fsdevel? it is way too easy to miss stuff like this when lkml is the only list it's sent to?

That said, the change looks good.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
Quoted 7 lines · Dave Chinner
Quoted 6 lines · Ross Zwisler

dax_pfn_mkwrite() previously wasn't checking the return value of the call to dax_radix_entry(), which was a mistake.

Instead, capture this return value and return the appropriate VM_FAULT_ value.

Quoted 6 lines
Quoted 1 line

Hi Ross,

Can you please cc dax stuff to linux-fsdevel? it is way too easy to miss stuff like this when lkml is the only list it's sent to?

Sure, will do.