* [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path
@ 2020-06-17 3:00 Souptick Joarder
2020-06-22 16:35 ` Souptick Joarder
0 siblings, 1 reply; 6+ messages in thread
From: Souptick Joarder @ 2020-06-17 3:00 UTC (permalink / raw)
To: jgg, dan.j.williams, gregkh, arnd, mchehab+samsung, akpm
Cc: dan.carpenter, linux-kernel, Souptick Joarder, John Hubbard
First, when memory allocation for sg_list_unaligned failed, there
is no point of calling put_pages() as we haven't pinned any pages.
Second, if get_user_pages_fast() failed we should unpinned num_pinned
pages, no point of checking till num_pages.
This will address both.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: John Hubbard <jhubbard@nvidia.com>
---
v2:
Added review tag.
drivers/virt/fsl_hypervisor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 1b0b11b..ea344d7 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
unsigned int i;
long ret = 0;
- int num_pinned; /* return value from get_user_pages() */
+ int num_pinned = 0; /* return value from get_user_pages() */
phys_addr_t remote_paddr; /* The next address in the remote buffer */
uint32_t count; /* The number of bytes left to copy */
@@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
exit:
if (pages) {
- for (i = 0; i < num_pages; i++)
+ for (i = 0; i < num_pinned; i++)
if (pages[i])
put_page(pages[i]);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path
2020-06-17 3:00 [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path Souptick Joarder
@ 2020-06-22 16:35 ` Souptick Joarder
2020-06-30 7:29 ` Souptick Joarder
0 siblings, 1 reply; 6+ messages in thread
From: Souptick Joarder @ 2020-06-22 16:35 UTC (permalink / raw)
To: Jason Gunthorpe, Dan Williams, Greg KH, Arnd Bergmann,
mchehab+samsung, Andrew Morton
Cc: Dan Carpenter, linux-kernel, John Hubbard
On Wed, Jun 17, 2020 at 8:22 AM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> First, when memory allocation for sg_list_unaligned failed, there
> is no point of calling put_pages() as we haven't pinned any pages.
>
> Second, if get_user_pages_fast() failed we should unpinned num_pinned
> pages, no point of checking till num_pages.
>
> This will address both.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
Any suggestion, what is the right tree to take this patch forward ?
> ---
> v2:
> Added review tag.
>
> drivers/virt/fsl_hypervisor.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
> index 1b0b11b..ea344d7 100644
> --- a/drivers/virt/fsl_hypervisor.c
> +++ b/drivers/virt/fsl_hypervisor.c
> @@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
>
> unsigned int i;
> long ret = 0;
> - int num_pinned; /* return value from get_user_pages() */
> + int num_pinned = 0; /* return value from get_user_pages() */
> phys_addr_t remote_paddr; /* The next address in the remote buffer */
> uint32_t count; /* The number of bytes left to copy */
>
> @@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
>
> exit:
> if (pages) {
> - for (i = 0; i < num_pages; i++)
> + for (i = 0; i < num_pinned; i++)
> if (pages[i])
> put_page(pages[i]);
> }
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path
2020-06-22 16:35 ` Souptick Joarder
@ 2020-06-30 7:29 ` Souptick Joarder
0 siblings, 0 replies; 6+ messages in thread
From: Souptick Joarder @ 2020-06-30 7:29 UTC (permalink / raw)
To: Jason Gunthorpe, Dan Williams, Greg KH, Arnd Bergmann,
mchehab+samsung, Andrew Morton
Cc: Dan Carpenter, linux-kernel, John Hubbard
On Mon, Jun 22, 2020 at 10:05 PM Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
> On Wed, Jun 17, 2020 at 8:22 AM Souptick Joarder <jrdr.linux@gmail.com> wrote:
> >
> > First, when memory allocation for sg_list_unaligned failed, there
> > is no point of calling put_pages() as we haven't pinned any pages.
> >
> > Second, if get_user_pages_fast() failed we should unpinned num_pinned
> > pages, no point of checking till num_pages.
> >
> > This will address both.
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> > Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Cc: John Hubbard <jhubbard@nvidia.com>
>
> Any suggestion, what is the right tree to take this patch forward ?
If no further comment, can we get this patch in queue for 5.9 ?
>
> > ---
> > v2:
> > Added review tag.
> >
> > drivers/virt/fsl_hypervisor.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
> > index 1b0b11b..ea344d7 100644
> > --- a/drivers/virt/fsl_hypervisor.c
> > +++ b/drivers/virt/fsl_hypervisor.c
> > @@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
> >
> > unsigned int i;
> > long ret = 0;
> > - int num_pinned; /* return value from get_user_pages() */
> > + int num_pinned = 0; /* return value from get_user_pages() */
> > phys_addr_t remote_paddr; /* The next address in the remote buffer */
> > uint32_t count; /* The number of bytes left to copy */
> >
> > @@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
> >
> > exit:
> > if (pages) {
> > - for (i = 0; i < num_pages; i++)
> > + for (i = 0; i < num_pinned; i++)
> > if (pages[i])
> > put_page(pages[i]);
> > }
> > --
> > 1.9.1
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path
2020-07-30 1:00 ` John Hubbard
@ 2020-08-25 20:20 ` Souptick Joarder
0 siblings, 0 replies; 6+ messages in thread
From: Souptick Joarder @ 2020-08-25 20:20 UTC (permalink / raw)
To: John Hubbard
Cc: Andrew Morton, Jason Gunthorpe, Dan Williams, Greg KH,
mchehab+samsung, linux-kernel, Dan Carpenter
On Thu, Jul 30, 2020 at 6:30 AM John Hubbard <jhubbard@nvidia.com> wrote:
>
> On 7/29/20 12:01 PM, Souptick Joarder wrote:
> > First, when memory allocation for sg_list_unaligned failed, there
> > is no point of calling put_pages() as we haven't pinned any pages.
> >
> > Second, if get_user_pages_fast() failed we should unpinned num_pinned
> > pages, no point of checking till num_pages.
>
> Hi Souptick,
>
> For both of the above, the wording "no point" is so overly gentle as
> to be misleading. That's because calling put_page() on any pages beyond
> num_pinned is a *bug*.
>
> So let's reword that. And let's change the patch subject from "Correcting" to
> "fix".
>
> And probably good to add a Fixes: tag, too.
Is there any scripts/ settings to fetch Fixes: tag other than using git blame ?
>
> More:
>
> >
> > This will address both.
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> > Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Cc: John Hubbard <jhubbard@nvidia.com>
> > ---
> > v2:
> > Added review tag.
> >
> > drivers/virt/fsl_hypervisor.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
> > index 1b0b11b..ea344d7 100644
> > --- a/drivers/virt/fsl_hypervisor.c
> > +++ b/drivers/virt/fsl_hypervisor.c
> > @@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
> >
> > unsigned int i;
> > long ret = 0;
> > - int num_pinned; /* return value from get_user_pages() */
> > + int num_pinned = 0; /* return value from get_user_pages() */
> > phys_addr_t remote_paddr; /* The next address in the remote buffer */
> > uint32_t count; /* The number of bytes left to copy */
> >
> > @@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
> >
> > exit:
> > if (pages) {
> > - for (i = 0; i < num_pages; i++)
> > + for (i = 0; i < num_pinned; i++)
> > if (pages[i])
>
> I suspect that this "if" is unnecessary now.
>
> Either way, the diff itself looks good to me, so with the wording changes to
> the commit description, you can add:
>
> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
>
> thanks,
> --
> John Hubbard
> NVIDIA
>
> > put_page(pages[i]);
> > }
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path
2020-07-29 19:01 Souptick Joarder
@ 2020-07-30 1:00 ` John Hubbard
2020-08-25 20:20 ` Souptick Joarder
0 siblings, 1 reply; 6+ messages in thread
From: John Hubbard @ 2020-07-30 1:00 UTC (permalink / raw)
To: Souptick Joarder, akpm
Cc: jgg, dan.j.williams, gregkh, mchehab+samsung, linux-kernel,
dan.carpenter
On 7/29/20 12:01 PM, Souptick Joarder wrote:
> First, when memory allocation for sg_list_unaligned failed, there
> is no point of calling put_pages() as we haven't pinned any pages.
>
> Second, if get_user_pages_fast() failed we should unpinned num_pinned
> pages, no point of checking till num_pages.
Hi Souptick,
For both of the above, the wording "no point" is so overly gentle as
to be misleading. That's because calling put_page() on any pages beyond
num_pinned is a *bug*.
So let's reword that. And let's change the patch subject from "Correcting" to
"fix".
And probably good to add a Fixes: tag, too.
More:
>
> This will address both.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> ---
> v2:
> Added review tag.
>
> drivers/virt/fsl_hypervisor.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
> index 1b0b11b..ea344d7 100644
> --- a/drivers/virt/fsl_hypervisor.c
> +++ b/drivers/virt/fsl_hypervisor.c
> @@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
>
> unsigned int i;
> long ret = 0;
> - int num_pinned; /* return value from get_user_pages() */
> + int num_pinned = 0; /* return value from get_user_pages() */
> phys_addr_t remote_paddr; /* The next address in the remote buffer */
> uint32_t count; /* The number of bytes left to copy */
>
> @@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
>
> exit:
> if (pages) {
> - for (i = 0; i < num_pages; i++)
> + for (i = 0; i < num_pinned; i++)
> if (pages[i])
I suspect that this "if" is unnecessary now.
Either way, the diff itself looks good to me, so with the wording changes to
the commit description, you can add:
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
thanks,
--
John Hubbard
NVIDIA
> put_page(pages[i]);
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path
@ 2020-07-29 19:01 Souptick Joarder
2020-07-30 1:00 ` John Hubbard
0 siblings, 1 reply; 6+ messages in thread
From: Souptick Joarder @ 2020-07-29 19:01 UTC (permalink / raw)
To: akpm
Cc: jgg, dan.j.williams, gregkh, mchehab+samsung, linux-kernel,
dan.carpenter, Souptick Joarder, John Hubbard
First, when memory allocation for sg_list_unaligned failed, there
is no point of calling put_pages() as we haven't pinned any pages.
Second, if get_user_pages_fast() failed we should unpinned num_pinned
pages, no point of checking till num_pages.
This will address both.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: John Hubbard <jhubbard@nvidia.com>
---
v2:
Added review tag.
drivers/virt/fsl_hypervisor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index 1b0b11b..ea344d7 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
unsigned int i;
long ret = 0;
- int num_pinned; /* return value from get_user_pages() */
+ int num_pinned = 0; /* return value from get_user_pages() */
phys_addr_t remote_paddr; /* The next address in the remote buffer */
uint32_t count; /* The number of bytes left to copy */
@@ -293,7 +293,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
exit:
if (pages) {
- for (i = 0; i < num_pages; i++)
+ for (i = 0; i < num_pinned; i++)
if (pages[i])
put_page(pages[i]);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-25 20:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 3:00 [PATCH v2] drivers/virt/fsl_hypervisor: Correcting error handling path Souptick Joarder
2020-06-22 16:35 ` Souptick Joarder
2020-06-30 7:29 ` Souptick Joarder
2020-07-29 19:01 Souptick Joarder
2020-07-30 1:00 ` John Hubbard
2020-08-25 20:20 ` Souptick Joarder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).