[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220613094928.164597971@linuxfoundation.org>
Date: Mon, 13 Jun 2022 12:10:00 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Si-Wei Liu <si-wei.liu@...cle.com>,
Jason Wang <jasowang@...hat.com>, Eli Cohen <elic@...dia.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.17 106/298] vdpa: Fix error logic in vdpa_nl_cmd_dev_get_doit
From: Eli Cohen <elic@...dia.com>
[ Upstream commit 7a6691f1f89784f775fa0c54be57533445726068 ]
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: bc0d90ee021f ("vdpa: Enable user to query vdpa device info")
Reviewed-by: Si-Wei Liu <si-wei.liu@...cle.com>
Acked-by: Jason Wang <jasowang@...hat.com>
Signed-off-by: Eli Cohen <elic@...dia.com>
Message-Id: <20220518133804.1075129-2-elic@...dia.com>
Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/vdpa/vdpa.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 1ea525433a5c..4e7351110e43 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -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;
}
--
2.35.1
Powered by blists - more mailing lists