Skip to content

Commit

Permalink
xen-netback: do not report success if backend_create_xenvif() fails
Browse files Browse the repository at this point in the history
If xenvif_alloc() or xenbus_scanf() fail in backend_create_xenvif(),
xenbus is left in offline mode but netback_probe() reports success.

The patch implements propagation of error code for backend_create_xenvif().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
Acked-by: Wei Liu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
khoroshilov authored and davem330 committed Nov 24, 2014
1 parent be6572f commit 2dd3433
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/net/xen-netback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct backend_info {
static int connect_rings(struct backend_info *be, struct xenvif_queue *queue);
static void connect(struct backend_info *be);
static int read_xenbus_vif_flags(struct backend_info *be);
static void backend_create_xenvif(struct backend_info *be);
static int backend_create_xenvif(struct backend_info *be);
static void unregister_hotplug_status_watch(struct backend_info *be);
static void set_backend_state(struct backend_info *be,
enum xenbus_state state);
Expand Down Expand Up @@ -352,7 +352,9 @@ static int netback_probe(struct xenbus_device *dev,
be->state = XenbusStateInitWait;

/* This kicks hotplug scripts, so do it immediately. */
backend_create_xenvif(be);
err = backend_create_xenvif(be);
if (err)
goto fail;

return 0;

Expand Down Expand Up @@ -397,30 +399,31 @@ static int netback_uevent(struct xenbus_device *xdev,
}


static void backend_create_xenvif(struct backend_info *be)
static int backend_create_xenvif(struct backend_info *be)
{
int err;
long handle;
struct xenbus_device *dev = be->dev;

if (be->vif != NULL)
return;
return 0;

err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
if (err != 1) {
xenbus_dev_fatal(dev, err, "reading handle");
return;
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;
xenbus_dev_fatal(dev, err, "creating interface");
return;
return err;
}

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

static void backend_disconnect(struct backend_info *be)
Expand Down

0 comments on commit 2dd3433

Please sign in to comment.