All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@linux.intel.com>
To: "Markus Armbruster" <armbru@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Michael Tokarev" <mjt@tls.msk.ru>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Zhao Liu <zhao1.liu@intel.com>,
	Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>,
	Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
Subject: [PATCH 06/16] block/nvme: Fix missing ERRP_GUARD() for error_prepend()
Date: Thu, 29 Feb 2024 00:37:13 +0800	[thread overview]
Message-ID: <20240228163723.1775791-7-zhao1.liu@linux.intel.com> (raw)
In-Reply-To: <20240228163723.1775791-1-zhao1.liu@linux.intel.com>

From: Zhao Liu <zhao1.liu@intel.com>

As the comment in qapi/error, passing @errp to error_prepend() requires
ERRP_GUARD():

* = Why, when and how to use ERRP_GUARD() =
*
* Without ERRP_GUARD(), use of the @errp parameter is restricted:
...
* - It should not be passed to error_prepend(), error_vprepend() or
*   error_append_hint(), because that doesn't work with &error_fatal.
* ERRP_GUARD() lifts these restrictions.
*
* To use ERRP_GUARD(), add it right at the beginning of the function.
* @errp can then be used without worrying about the argument being
* NULL or &error_fatal.

ERRP_GUARD() could avoid the case when @errp is the pointer of
error_fatal, the user can't see this additional information, because
exit() happens in error_setg earlier than information is added [1].

In nvme.c, there're 3 functions passing @errp to error_prepend()
without ERRP_GUARD():
- nvme_init_queue()
- nvme_create_queue_pair()
- nvme_identify()

All these 3 functions take their @errp parameters from the
nvme_file_open(), which is a BlockDriver.bdrv_nvme() method and its
@errp points to its caller's local_err.

Though these 3 cases haven't trigger the issue like [1] said, to
follow the requirement of @errp, add missing ERRP_GUARD() at their
beginning.

[1]: Issue description in the commit message of commit ae7c80a7bd73
     ("error: New macro ERRP_GUARD()").

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Fam Zheng <fam@euphon.net>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 block/nvme.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/nvme.c b/block/nvme.c
index 0a0a0a6b36cd..3a3c6da73d29 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -168,6 +168,7 @@ static QemuOptsList runtime_opts = {
 static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
                             unsigned nentries, size_t entry_bytes, Error **errp)
 {
+    ERRP_GUARD();
     size_t bytes;
     int r;
 
@@ -221,6 +222,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
                                              unsigned idx, size_t size,
                                              Error **errp)
 {
+    ERRP_GUARD();
     int i, r;
     NVMeQueuePair *q;
     uint64_t prp_list_iova;
@@ -535,6 +537,7 @@ static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd)
 /* Returns true on success, false on failure. */
 static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
 {
+    ERRP_GUARD();
     BDRVNVMeState *s = bs->opaque;
     bool ret = false;
     QEMU_AUTO_VFREE union {
-- 
2.34.1



  parent reply	other threads:[~2024-02-28 16:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 16:37 [PATCH 00/16 Part 1] Cleanup up to fix missing ERRP_GUARD() for error_prepend() Zhao Liu
2024-02-28 16:37 ` [PATCH 01/16] error: Add error_vprepend() in comment of ERRP_GUARD() rules Zhao Liu
2024-02-29 14:42   ` Markus Armbruster
2024-02-29 15:50     ` Zhao Liu
2024-02-28 16:37 ` [PATCH 02/16] backends/iommufd: Fix missing ERRP_GUARD() for error_prepend() Zhao Liu
2024-02-29  3:03   ` Duan, Zhenzhong
2024-02-28 16:37 ` [PATCH 03/16] block: " Zhao Liu
2024-02-29 19:51   ` Eric Blake
2024-03-08 11:09     ` Zhao Liu
2024-02-28 16:37 ` [PATCH 04/16] block/cbw: " Zhao Liu
2024-02-28 16:30   ` Vladimir Sementsov-Ogievskiy
2024-02-28 16:50     ` Zhao Liu
2024-02-28 16:37 ` [PATCH 05/16] block/nbd: " Zhao Liu
2024-02-28 16:31   ` Vladimir Sementsov-Ogievskiy
2024-02-28 16:37 ` Zhao Liu [this message]
2024-02-28 18:42   ` [PATCH 06/16] block/nvme: " Stefan Hajnoczi
2024-02-28 16:37 ` [PATCH 07/16] block/qcow2-bitmap: " Zhao Liu
2024-02-28 16:32   ` Vladimir Sementsov-Ogievskiy
2024-02-28 16:37 ` [PATCH 08/16] block/qcow2: " Zhao Liu
2024-02-29 20:48   ` Eric Blake
2024-03-08 11:08     ` Zhao Liu
2024-02-28 16:37 ` [PATCH 09/16] block/qed: " Zhao Liu
2024-02-28 18:42   ` Stefan Hajnoczi
2024-02-28 16:37 ` [PATCH 10/16] block/snapshot: " Zhao Liu
2024-02-28 16:37 ` [PATCH 11/16] block/vdi: " Zhao Liu
2024-02-28 16:37 ` [PATCH 12/16] block/vmdk: " Zhao Liu
2024-02-28 16:37 ` [PATCH 13/16] block/virtio-blk: " Zhao Liu
2024-02-28 18:42   ` Stefan Hajnoczi
2024-02-28 20:30   ` Michael S. Tsirkin
2024-02-28 16:37 ` [PATCH 14/16] hw/char/xen_console: " Zhao Liu
2024-03-08 15:31   ` Anthony PERARD
2024-02-28 16:37 ` [PATCH 15/16] hw/core/loader-fit: " Zhao Liu
2024-02-28 16:37 ` [PATCH 16/16] hw/core/qdev-properties-system: " Zhao Liu
2024-02-29 14:48   ` Markus Armbruster
2024-02-29 15:55     ` Zhao Liu
2024-02-29 16:02       ` Markus Armbruster

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=20240228163723.1775791-7-zhao1.liu@linux.intel.com \
    --to=zhao1.liu@linux.intel.com \
    --cc=armbru@redhat.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=mjt@tls.msk.ru \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhao1.liu@intel.com \
    /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.