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
[ Upstream commit 7a6691f ]

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 <si-wei.liu@oracle.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Eli Cohen <elic@nvidia.com>
Message-Id: <20220518133804.1075129-2-elic@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
elic307i authored and gregkh committed Jun 14, 2022
1 parent 4a45a7d commit 655aafa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/vdpa/vdpa.c
Expand Up @@ -558,14 +558,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 655aafa

Please sign in to comment.