diff mbox

x86/mm: Fix Coverity issues 1373105 and 1373106

Message ID 1474460758-25367-1-git-send-email-rcojocaru@bitdefender.com (mailing list archive)
State New, archived
Headers show

Commit Message

Razvan Cojocaru Sept. 21, 2016, 12:25 p.m. UTC
Added missing error checks in p2m_set_mem_access_multi().

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
---
 xen/arch/x86/mm/p2m.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Razvan Cojocaru Sept. 21, 2016, 12:32 p.m. UTC | #1
On 09/21/2016 03:25 PM, Razvan Cojocaru wrote:
> Added missing error checks in p2m_set_mem_access_multi().
> 
> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
> ---
>  xen/arch/x86/mm/p2m.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
> index b16e563..e850510 100644
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -1936,8 +1936,12 @@ long p2m_set_mem_access_multi(struct domain *d,
>          uint8_t access;
>          uint64_t gfn_l;
>  
> -        copy_from_guest_offset(&gfn_l, pfn_list, start, 1);
> -        copy_from_guest_offset(&access, access_list, start, 1);
> +        if ( copy_from_guest_offset(&gfn_l, pfn_list, start, 1) ||
> +             copy_from_guest_offset(&access, access_list, start, 1) )
> +        {
> +            rc = -EINVAL;
> +	    break;

There seems to have been an accident here with a TAB getting inserted
instead of spaces. If it can't be fixed on commit I'll resend.


Thanks,
Razvan
Jan Beulich Sept. 21, 2016, 12:33 p.m. UTC | #2
>>> On 21.09.16 at 14:25, <rcojocaru@bitdefender.com> wrote:
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -1936,8 +1936,12 @@ long p2m_set_mem_access_multi(struct domain *d,
>          uint8_t access;
>          uint64_t gfn_l;
>  
> -        copy_from_guest_offset(&gfn_l, pfn_list, start, 1);
> -        copy_from_guest_offset(&access, access_list, start, 1);
> +        if ( copy_from_guest_offset(&gfn_l, pfn_list, start, 1) ||
> +             copy_from_guest_offset(&access, access_list, start, 1) )
> +        {
> +            rc = -EINVAL;

-EFAULT

> +	    break;

Bogus tab.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index b16e563..e850510 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1936,8 +1936,12 @@  long p2m_set_mem_access_multi(struct domain *d,
         uint8_t access;
         uint64_t gfn_l;
 
-        copy_from_guest_offset(&gfn_l, pfn_list, start, 1);
-        copy_from_guest_offset(&access, access_list, start, 1);
+        if ( copy_from_guest_offset(&gfn_l, pfn_list, start, 1) ||
+             copy_from_guest_offset(&access, access_list, start, 1) )
+        {
+            rc = -EINVAL;
+	    break;
+        }
 
         if ( !xenmem_access_to_p2m_access(p2m, access, &a) )
         {