Skip to content

Commit

Permalink
vdpa: Fix error logic in vdpa_nl_cmd_dev_get_doit
Browse files Browse the repository at this point in the history
In vdpa_nl_cmd_dev_get_doit(), if the call to genlmsg_reply() fails we
must not call nlmsg_free() since this is done inside genlmsg_reply().

Fix it.

Fixes: bc0d90e ("vdpa: Enable user to query vdpa device info")
Reviewed-by: Si-Wei Liu <[email protected]>
Acked-by: Jason Wang <[email protected]>
Signed-off-by: Eli Cohen <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
elic307i authored and mstsirkin committed May 31, 2022
1 parent 8ab2afa commit 7a6691f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/vdpa/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,19 @@ static int vdpa_nl_cmd_dev_get_doit(struct sk_buff *skb, struct genl_info *info)
goto mdev_err;
}
err = vdpa_dev_fill(vdev, msg, info->snd_portid, info->snd_seq, 0, info->extack);
if (!err)
err = genlmsg_reply(msg, info);
if (err)
goto mdev_err;

err = genlmsg_reply(msg, info);
put_device(dev);
mutex_unlock(&vdpa_dev_mutex);
return err;

mdev_err:
put_device(dev);
err:
mutex_unlock(&vdpa_dev_mutex);
if (err)
nlmsg_free(msg);
nlmsg_free(msg);
return err;
}

Expand Down

0 comments on commit 7a6691f

Please sign in to comment.