All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eli Cohen <elic@nvidia.com>
To: <mst@redhat.com>, <jasowang@redhat.com>
Cc: <virtualization@lists.linux-foundation.org>,
	<linux-kernel@vger.kernel.org>, <si-wei.liu@oracle.com>,
	Eli Cohen <elic@nvidia.com>
Subject: [PATCH v5 1/3] vdpa: Fix error logic in vdpa_nl_cmd_dev_get_doit
Date: Tue, 10 May 2022 14:27:32 +0300	[thread overview]
Message-ID: <20220510112734.205669-2-elic@nvidia.com> (raw)
In-Reply-To: <20220510112734.205669-1-elic@nvidia.com>

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")
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Eli Cohen <elic@nvidia.com>
---
 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 2b75c00b1005..fac89a0d8178 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


  reply	other threads:[~2022-05-10 11:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 11:27 [PATCH v5 0/3] Show statistics for a vdpa device Eli Cohen
2022-05-10 11:27 ` Eli Cohen [this message]
2022-05-10 16:18   ` [PATCH v5 1/3] vdpa: Fix error logic in vdpa_nl_cmd_dev_get_doit Si-Wei Liu
2022-05-10 16:18     ` Si-Wei Liu
2022-05-10 11:27 ` [PATCH v5 2/3] vdpa: Add support for querying vendor statistics Eli Cohen
2022-05-11 18:15   ` Si-Wei Liu
2022-05-11 18:15     ` Si-Wei Liu
2022-05-10 11:27 ` [PATCH v5 3/3] vdpa/mlx5: Add support for reading descriptor statistics Eli Cohen
2022-05-11 17:25   ` Si-Wei Liu
2022-05-11 17:25     ` Si-Wei Liu
2022-05-12  2:27     ` Jason Wang
2022-05-12  2:27       ` Jason Wang
2022-05-12  5:29       ` Eli Cohen
2022-05-13  1:10       ` Si-Wei Liu
2022-05-13  1:10         ` Si-Wei Liu
2022-05-12 21:13     ` Si-Wei Liu
2022-05-12 21:15     ` Si-Wei Liu
2022-05-12 21:15       ` Si-Wei Liu
2022-05-16  6:05       ` Eli Cohen
2022-05-12 21:16     ` Si-Wei Liu
2022-05-12 21:16       ` Si-Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220510112734.205669-2-elic@nvidia.com \
    --to=elic@nvidia.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=si-wei.liu@oracle.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.