Skip to content

Commit

Permalink
netback: don't store invalid vif pointer
Browse files Browse the repository at this point in the history
When xenvif_alloc() fails, it returns a non-NULL error indicator. To
avoid eventual races, we shouldn't store that into struct backend_info
as readers of it only check for NULL.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jan Beulich authored and David S. Miller committed Dec 9, 2014
1 parent ceaca9d commit f15650b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/net/xen-netback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ static int backend_create_xenvif(struct backend_info *be)
int err;
long handle;
struct xenbus_device *dev = be->dev;
struct xenvif *vif;

if (be->vif != NULL)
return 0;
Expand All @@ -414,13 +415,13 @@ static int backend_create_xenvif(struct backend_info *be)
return (err < 0) ? err : -EINVAL;
}

be->vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
if (IS_ERR(be->vif)) {
err = PTR_ERR(be->vif);
be->vif = NULL;
vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
if (IS_ERR(vif)) {
err = PTR_ERR(vif);
xenbus_dev_fatal(dev, err, "creating interface");
return err;
}
be->vif = vif;

kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE);
return 0;
Expand Down

0 comments on commit f15650b

Please sign in to comment.