From nobody Mon Feb 9 09:34:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007442; cv=none; d=zohomail.com; s=zohoarc; b=grF+D4mx1uU9SQlWxKanpBAK2HBouWJMzpGSe+gy74K4IaEmLIbXzkJJW5pfUjduyuV4XdaJQxgR1M9uM5/KS75IQZjOiFE+iLuuwptZVqfOzLzGfZK1b7NSkeZLzqbqC0Isz3UDmMt/iaWSXo2Io2tzi4cg3YNzMFduBNpirp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007442; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=bFt+6oWlQ/AFxXO/DDwfj3le4CbIqY5N4MqNl4HgIj5XBHSGR+UH8QjZ28WF2PdAZIPMsmGfzb/4adSyi+bUKV9lT4fqaPfC/48dVcE5Ra6s04MJ+9RScqkd8VuSszmogZoXkKnr6XDLK3+9nvtyZ6oVA+NktN0S+cBwBEAA720= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630007442182292.435742052704; Thu, 26 Aug 2021 12:50:42 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-M5h9E3WvPN2Vv3Ol9hDnKA-1; Thu, 26 Aug 2021 15:50:39 -0400 Received: by mail-wm1-f69.google.com with SMTP id g3-20020a1c2003000000b002e751c4f439so4766074wmg.7 for ; Thu, 26 Aug 2021 12:50:39 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id f17sm4740029wrt.63.2021.08.26.12.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=QVIIlE/3c9tH/Ffa4YlIVJTCvPW+V3S/njuOwZVLOwFcuZivTUU4oGfFEJ7WfYEjxUBEnZ IEwhqoV2vFhyEu0cIrDXC04h1HeVBJ8oIPMwzzL/6uHpCcgATka8uPLV9A2k4ZPj8xZGol gwUEIV9NeQnI2UMbg4k3S0ahjegu7Vo= X-MC-Unique: M5h9E3WvPN2Vv3Ol9hDnKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=ZZRcF6rMkXtElL8E9aLjd1VKbB4SFiGzo/MH7xRxmsMkz2dWYec+X2vTVrttSKzXg5 RBLBxwaRv1LnDJb8J0BIXVuIKj+nnuCuzhh7/dwUxhI0Zpu4kjDgNJl65y488aj15wY3 A2BBHtxh8ImLA4vExhp4yPCU6I+RBa/luPiXsVxvRTa05goOQOHUptsiAVGQG9aHsCgF lUP08jtkQGtsMxRPAIdlRhugUF5IMjlPxbJvB7iR8C7RvUbuhT535dwZ1VSFwiQfuqh/ PpODnreomdppHFYc7ppbtMkDz2ew2ofp5LeeAlg4xQlcZ0yTMnvw+uRhwRrS0Qs7ar/O bvrw== X-Gm-Message-State: AOAM532r9/BXCOfCShhGDTE5NS9n+PBUizyHDmzGBhCkWeLfMS8PLPvr PIXxXkGtuKzQ7w4+0DF2GlXTDpYxmAbLNi8DvB4Q0RYcX5K7CJCvfiBbecp7fTv317sgFxdGeKF qIDETVBFDxF3YQw== X-Received: by 2002:a1c:a78a:: with SMTP id q132mr5286213wme.91.1630007438274; Thu, 26 Aug 2021 12:50:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzonunia3BcQMWDDq13LsVtb9ObTCUsM75OJ/BHlnjwD0+Af0ay6Lz2YeQ4v6ltjDugUGcXzA== X-Received: by 2002:a1c:a78a:: with SMTP id q132mr5286198wme.91.1630007438147; Thu, 26 Aug 2021 12:50:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric Subject: [PATCH v2 05/11] block/nvme: Have nvme_create_queue_pair() report errors consistently Date: Thu, 26 Aug 2021 21:50:08 +0200 Message-Id: <20210826195014.2180369-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826195014.2180369-1-philmd@redhat.com> References: <20210826195014.2180369-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007443441100001 nvme_create_queue_pair() does not return a boolean value (indicating eventual error) but a pointer, and is inconsistent in how it fills the error handler. To fulfill callers expectations, always set an error message on failure. Reported-by: Auger Eric Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index e8dbbc23177..0786c501e46 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -220,6 +220,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, =20 q =3D g_try_new0(NVMeQueuePair, 1); if (!q) { + error_setg(errp, "Cannot allocate queue pair"); return NULL; } trace_nvme_create_queue_pair(idx, q, size, aio_context, @@ -228,6 +229,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, qemu_real_host_page_size); q->prp_list_pages =3D qemu_try_memalign(qemu_real_host_page_size, byte= s); if (!q->prp_list_pages) { + error_setg(errp, "Cannot allocate PRP page list"); goto fail; } memset(q->prp_list_pages, 0, bytes); @@ -239,6 +241,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, r =3D qemu_vfio_dma_map(s->vfio, q->prp_list_pages, bytes, false, &prp_list_iova); if (r) { + error_setg_errno(errp, -r, "Cannot map buffer for DMA"); goto fail; } q->free_req_head =3D -1; --=20 2.31.1