* [PATCH] dax: check return value of dax_radix_entry()
@ 2016-03-01 22:15 ` Ross Zwisler
0 siblings, 0 replies; 6+ messages in thread
From: Ross Zwisler @ 2016-03-01 22:15 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton, linux-nvdimm
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.
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
fs/dax.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/dax.c b/fs/dax.c
index 7111724..5a587dc 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -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);
--
2.5.0
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] dax: check return value of dax_radix_entry()
@ 2016-03-01 22:15 ` Ross Zwisler
0 siblings, 0 replies; 6+ messages in thread
From: Ross Zwisler @ 2016-03-01 22:15 UTC (permalink / raw)
To: linux-kernel
Cc: Ross Zwisler, Andrew Morton, Dan Williams, Matthew Wilcox, linux-nvdimm
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.
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
fs/dax.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/dax.c b/fs/dax.c
index 7111724..5a587dc 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -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);
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] dax: check return value of dax_radix_entry()
2016-03-01 22:15 ` Ross Zwisler
@ 2016-03-02 14:09 ` Matthew Wilcox
-1 siblings, 0 replies; 6+ messages in thread
From: Matthew Wilcox @ 2016-03-02 14:09 UTC (permalink / raw)
To: Ross Zwisler; +Cc: Andrew Morton, linux-kernel, linux-nvdimm
On Tue, Mar 01, 2016 at 03:15:08PM -0700, Ross Zwisler wrote:
> 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.
> */
> - 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;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dax: check return value of dax_radix_entry()
@ 2016-03-02 14:09 ` Matthew Wilcox
0 siblings, 0 replies; 6+ messages in thread
From: Matthew Wilcox @ 2016-03-02 14:09 UTC (permalink / raw)
To: Ross Zwisler; +Cc: linux-kernel, Andrew Morton, Dan Williams, linux-nvdimm
On Tue, Mar 01, 2016 at 03:15:08PM -0700, Ross Zwisler wrote:
> 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.
> */
> - 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dax: check return value of dax_radix_entry()
2016-03-02 14:09 ` Matthew Wilcox
@ 2016-03-02 16:33 ` Ross Zwisler
-1 siblings, 0 replies; 6+ messages in thread
From: Ross Zwisler @ 2016-03-02 16:33 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: linux-kernel, Andrew Morton, linux-nvdimm
On Wed, Mar 02, 2016 at 09:09:47AM -0500, Matthew Wilcox wrote:
> On Tue, Mar 01, 2016 at 03:15:08PM -0700, Ross Zwisler wrote:
> > 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.
>
> > */
> > - 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;
Ah, thank you for catching that.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dax: check return value of dax_radix_entry()
@ 2016-03-02 16:33 ` Ross Zwisler
0 siblings, 0 replies; 6+ messages in thread
From: Ross Zwisler @ 2016-03-02 16:33 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Ross Zwisler, linux-kernel, Andrew Morton, Dan Williams, linux-nvdimm
On Wed, Mar 02, 2016 at 09:09:47AM -0500, Matthew Wilcox wrote:
> On Tue, Mar 01, 2016 at 03:15:08PM -0700, Ross Zwisler wrote:
> > 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.
>
> > */
> > - 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;
Ah, thank you for catching that.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-03-02 16:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-01 22:15 [PATCH] dax: check return value of dax_radix_entry() Ross Zwisler
2016-03-01 22:15 ` Ross Zwisler
2016-03-02 14:09 ` Matthew Wilcox
2016-03-02 14:09 ` Matthew Wilcox
2016-03-02 16:33 ` Ross Zwisler
2016-03-02 16:33 ` Ross Zwisler
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.