From nobody Fri May 17 06:07:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1690285050; cv=none; d=zohomail.com; s=zohoarc; b=aO5S4A/w8PiYVt8y8ECnqsfO2zPr5IIFDXvxUbM1Ypp1tyUuYotJqpVeh1FrlKmyuWlBGjo+ovLGweAPgOarZlB+2eoImSY9NLT8aAGky1Bon50w9Adr6C/+LUeLAwl3wv1lvyY0RXyb5gcgF3KJv9kE0mbOo8ocJYe6zNEh4cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690285050; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=bC0bCZ58IqNs3NqhqGiDnifR7I06Ib8a2gTe2OIYgyk=; b=e59GkqhlI9VyI2r6BE+xb30oYfj34ueF7TFhSKTtIB0wFm3S4XyHzhSP6X5IFxVVv8poRgql8MnKpp3BT5FnlZ1OiN/cMtHQX3Cub4hvIKciBIiD7CJhzI7/tploQxLOqj3S1ZYAihIkHoCLCAxMWWxebaJVFLBYJMHrUkNzzw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690285050075143.90730499737572; Tue, 25 Jul 2023 04:37:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOGLH-0001yU-JF; Tue, 25 Jul 2023 07:36:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOGLF-0001y2-J9 for qemu-devel@nongnu.org; Tue, 25 Jul 2023 07:36:37 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qOGLD-0007oM-Tb for qemu-devel@nongnu.org; Tue, 25 Jul 2023 07:36:37 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-316eabffaa6so4040966f8f.2 for ; Tue, 25 Jul 2023 04:36:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id m9-20020a5d56c9000000b00313e2abfb8dsm16263596wrw.92.2023.07.25.04.36.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 04:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690284994; x=1690889794; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bC0bCZ58IqNs3NqhqGiDnifR7I06Ib8a2gTe2OIYgyk=; b=DxLsfi1KSNWceDtjDZtGQD1Rl4pXbMEQADx2+pipGvZcQKHZ76iVWzmr/r29nyhVds r2ZGdC2234FL1uvTr11pgDjynIqBbk7laVXg+FDb8kuO5VRc1Rk5Z5F6tGNv3h7ClHHx WxmzrHDpOiaunVBOXJ1uMhapRMUoiMJRFzdKa0PyQp3S/ld+tCboOrnnYAns9l86I+bw Sx5ui0U6q+EG8fALeN4qZfNfUigTZTlb7nldv4KEaZd5QGQWUzVTNCt1uO9ioBPku7xy viOc0uxacXiWJRwcziO5Fs3Re2JDod5oaB5IvgQfu0Uzis4ZwW4I9iOSyyp5IMe8605Q 55qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690284994; x=1690889794; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bC0bCZ58IqNs3NqhqGiDnifR7I06Ib8a2gTe2OIYgyk=; b=C8ht5qtDu+qlnJkbVDcclsYawXLUntN8G9iXvezh6A6jfkbWPChg4ha8mkm5zKRkuW NGUHboRH0Tr8DQSGaP8r0D8mXuqGj3Utjbr1HqA0URx/7Q7KOKduypDNcHGCM3mI1uAM KtJfvknBih/ukMC4oLrZrw6dDv0IbBDPZPHy1SZNJ0geelZ6PZS5K0uYHuiadDkaLCHt T8FM/x/0ldbwq7nphonS1h4WOOxsk+ybse2kPUmcLKDauTFr13aGQsZ/4MuatwmWbzIw dn5lsxoJi/MPGvpDkuYNKai64xiJ4y80mMXWHxPuWRZOoRUScKSICNv5qLoq5t+WIZW+ Ilrg== X-Gm-Message-State: ABy/qLYwQ27I3Idgc2ZznAxozXn6RJPGCGWCXiCsu/MAufABz0EiBBQj xotQO0ltxlcICL8K6dF/X4wi1SO13IenJs0zymg= X-Google-Smtp-Source: APBJJlFDt6x+db+7PjHK62TROdghcr3FNlHXv1qGWcqlCQ3M/RLIn+WjiE6xOJEZGESKjEAeXGTjHw== X-Received: by 2002:adf:f1c4:0:b0:315:a043:5e0a with SMTP id z4-20020adff1c4000000b00315a0435e0amr9096563wro.56.1690284993979; Tue, 25 Jul 2023 04:36:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Yuval Shaia , Marcel Apfelbaum Subject: [PATCH for-8.1] hw/rdma/vmw/pvrdma_cmd: Use correct struct in query_port() Date: Tue, 25 Jul 2023 12:36:32 +0100 Message-Id: <20230725113632.2386874-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1690285052430100003 Content-Type: text/plain; charset="utf-8" In query_port() we pass the address of a local pvrdma_port_attr struct to the rdma_query_backend_port() function. Unfortunately, rdma_backend_query_port() wants a pointer to a struct ibv_port_attr, and the two are not the same length. Coverity spotted this (CID 1507146): pvrdma_port_attr is 48 bytes long, and ibv_port_attr is 52 bytes, because it has a few extra fields at the end. Fortunately, all we do with the attrs struct after the call is to read a few specific fields out of it which are all at the same offsets in both structs, so we can simply make the local variable the correct type. This also lets us drop the cast (which should have been a bit of a warning flag that we were doing something wrong here). Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- I don't know anything about the rdma code so this fix is based purely on looking at the code, and is untested beyond just make check/make check-avocado. --- hw/rdma/vmw/pvrdma_cmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c index c6ed0259821..d31c1875938 100644 --- a/hw/rdma/vmw/pvrdma_cmd.c +++ b/hw/rdma/vmw/pvrdma_cmd.c @@ -129,14 +129,13 @@ static int query_port(PVRDMADev *dev, union pvrdma_cm= d_req *req, { struct pvrdma_cmd_query_port *cmd =3D &req->query_port; struct pvrdma_cmd_query_port_resp *resp =3D &rsp->query_port_resp; - struct pvrdma_port_attr attrs =3D {}; + struct ibv_port_attr attrs =3D {}; =20 if (cmd->port_num > MAX_PORTS) { return -EINVAL; } =20 - if (rdma_backend_query_port(&dev->backend_dev, - (struct ibv_port_attr *)&attrs)) { + if (rdma_backend_query_port(&dev->backend_dev, &attrs)) { return -ENOMEM; } =20 --=20 2.34.1