From patchwork Tue Jul 25 11:36:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 706139 Delivered-To: patch@linaro.org Received: by 2002:a5d:464f:0:b0:317:2194:b2bc with SMTP id j15csp126678wrs; Tue, 25 Jul 2023 04:37:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEJlFPsdH0RBDgj4YgMVkBer7vH4ZQB2n5ee4pDTIGjpd8BESK4lMmSym8fhqK/+kAELLh1 X-Received: by 2002:a81:66c4:0:b0:565:3749:c24d with SMTP id a187-20020a8166c4000000b005653749c24dmr9184999ywc.14.1690285049729; Tue, 25 Jul 2023 04:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690285049; cv=none; d=google.com; s=arc-20160816; b=B0k5nDB31NeHeKlD12rSQNtaFjXPz2Yy4e0N1GNVdzVwcQ+6frbuRlZU6NU6NLSj0g Ner6O2aAF3WNsnp2PSe41VU3bJ91+RGcfr5sHbn8TCcIWau2vtzi5peSxaMIDmYAjBHE e0NAeCmfKEV2gfCq/XwHUFOm+UYBz3/yPOi7y/3mNmPe9+zViYU9epg7sDRBr/z1XDy2 okTm2zJx1HV/pgpkRMT+3timKk+6gxTBET6AYo1ivNloKxZ9B5DDAwUjXXgpNr6dSCGk XDVGJLJ7ktI6CdiSkmVYR4smNPBJ87reoWm0rNqriFbzskeuHw7Z4hrngbPyzZqzSn3e K6BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=bC0bCZ58IqNs3NqhqGiDnifR7I06Ib8a2gTe2OIYgyk=; fh=cJ4WEGirb2t9V1X1GOZbrKIUAZD4kBp4x+6JhjzXDYw=; b=OFBX0Pt/yU2IPuQLemxlFr83EybmwnM2LXDjSLJUNHzRneSL0TCT05FkikLK/nQcqe FWt7FYW7XI7QvFNwdmQfd8x5d58r2SWpOoFa2Gc2vr0vYzWDfMDRmB9fMUmFkR0u+gEP bcA59WRs9PF8geHFtV6hG1utmNbXUyDGXbUc61nPoEMY+fp2iYRQE7040YlGFVy5vkdy nvu5EeJa27abBB20tCRsEErVnLDmyQQpAVWuxnJ8rgh7eI7J+qQGRepETd3/Mrum4C4x FO8hOYN5wR5F3OUv03Sw6SfHph4A3WqtH3nMT5oBPKVpfUEfwVlQQEabX2SSu8Mz6Qmy M4dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DxLsfi1K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 9-20020ac85949000000b00405516e0cd1si5101958qtz.445.2023.07.25.04.37.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jul 2023 04:37:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DxLsfi1K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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_cmd_req *req, { struct pvrdma_cmd_query_port *cmd = &req->query_port; struct pvrdma_cmd_query_port_resp *resp = &rsp->query_port_resp; - struct pvrdma_port_attr attrs = {}; + struct ibv_port_attr attrs = {}; if (cmd->port_num > MAX_PORTS) { return -EINVAL; } - if (rdma_backend_query_port(&dev->backend_dev, - (struct ibv_port_attr *)&attrs)) { + if (rdma_backend_query_port(&dev->backend_dev, &attrs)) { return -ENOMEM; }