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] Null-pointer access in netback_uevent

Check if drvdata has been set up yet and return if it hasn't

Signed-off-by: James Harper <james.harper@xxxxxxxxxxxxxxxx>
---
 drivers/xen/netback/xenbus.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/netback/xenbus.c b/drivers/xen/netback/xenbus.c
index 70636d0..a46d8b2 100644
--- a/drivers/xen/netback/xenbus.c
+++ b/drivers/xen/netback/xenbus.c
@@ -162,12 +162,16 @@ fail:
  */
 static int netback_uevent(struct xenbus_device *xdev, struct kobj_uevent_env 
*env)
 {
-       struct backend_info *be = dev_get_drvdata(&xdev->dev);
-       struct xen_netif *netif = be->netif;
+       struct backend_info *be;
+       struct xen_netif *netif;
        char *val;

        DPRINTK("netback_uevent");

+       be = dev_get_drvdata(&xdev->dev);
+       if (!be)
+               return 0;
+       netif = be->netif;
        val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
        if (IS_ERR(val)) {
                int err = PTR_ERR(val);
--
1.7.1


> -----Original Message-----
> From: Jeremy Fitzhardinge [mailto:jeremy@xxxxxxxx]
> Sent: Saturday, 29 May 2010 09:31
> To: James Harper
> Cc: Bastian Blank; xen-devel@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [Xen-devel] Null-pointer access in netback_uevent
> 
> On 05/28/2010 03:42 PM, James Harper wrote:
> >>>> Looking into this further, I suspect that the trigger here is a newer
> >>>> version of udev or something in that area. netback_uevent is getting
> called
> >>>> before the call to netback_probe containing the call to dev_set_drvdata.
> >>>>
> >>>>
> >>> There are two problems there. And yes, the uevent routine can be called
> >>> at any time.
> >>>
> >>>
> >> So would it be correct for it to just return if either of those are
> >> NULL?
> >>
> > Not sure. It works though.
> >
> 
> Can you send me a properly signed-off patch?
> 
> Thanks,
>     J
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel