dax: check return value of dax_radix_entry()
PATCH 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 pass it up the stack if it is an error.
--- fs/dax.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/dax.c +6 -1
@@ -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,11 @@ 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) +return error; +return VM_FAULT_NOPAGE ; }EXPORT_SYMBOL_GPL (dax_pfn_mkwrite);
Signature · 1 line
2.5.0
Quoted 6 lines · Ross Zwisler
dax_pfn_mkwrite()previously wasn't checking the return value of the call todax_radix_entry(), which was a mistake.Instead, capture this return value and pass it up the stack if it is an error.
fs/dax.c int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1074
Quoted 8 lines
fs/dax.c +5
-1*/ -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) +return error; +return VM_FAULT_NOPAGE ;
You can't return an errno from here.
if (error) return VM_FAULT_SIGBUS;
is better. For full points,
if (error == -ENOMEM) return VM_FAULT_OOM; if (error) return VM_FAULT_SIGBUS; return VM_FAULT_NOPAGE;
Quoted 21 lines · Matthew Wilcox
Quoted 6 lines · Ross Zwisler
dax_pfn_mkwrite()previously wasn't checking the return value of the call todax_radix_entry(), which was a mistake.Instead, capture this return value and pass it up the stack if it is an error.
fs/dax.c int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) · line 1074
Quoted 8 lines
fs/dax.c +5
-1*/ -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) +return error; +return VM_FAULT_NOPAGE ;You can't return an errno from here.
if (error) return VM_FAULT_SIGBUS;
Quoted 7 lines
is better. For full points,
if (error == -ENOMEM) return VM_FAULT_OOM; if (error) return VM_FAULT_SIGBUS; return VM_FAULT_NOPAGE;
Ah, thank you for catching that.