WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] Null pointer dereference at free_vm_area()

To: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] Null pointer dereference at free_vm_area()
From: glommer@xxxxxxxxxx (Glauber de Oliveira Costa)
Date: Tue, 27 Dec 2005 14:17:23 -0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 27 Dec 2005 16:14:05 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20051227155449.GB4126@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20051226155857.GA14912@xxxxxxxxxx> <20051227155449.GB4126@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
> 
> Hi,
> 
> I quickly look around where free_vm_area is called, and I cannot see any
> codepath that could benefit such a code cleanup nor find any that
> could lead to a NULL pointer pass to it.
> 
> I think you should provide a use for this patch if you want it to be
> applied.
> 
> Thanks,
> -- 
> Vincent Hanquez
> 
I think it's more stylish than functional nowadays. In a situations in which we 
call alloc_vm_area() more than once, and test for the return value of them all 
in one shot. It can maybe lead to a cleaner code, as shown in the
pseudocode bellow. 

a1 = alloc_vm_area()
a2 = alloc_vm_area()

if (!a1 || !a2){
        free_vm_area(a1);
        free_vm_area(a2);
        return;
}

Instead of:

a1 = alloc_vm_area();
if (!a1)
        return;
a2 = alloc_vm_area()
if (!a2){
        free_vm_area(a1);
        return;
}

But of course, it's mainly a matter of opinion.

-- 
glommer

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>