Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2726rdb; Wed, 29 Nov 2023 17:33:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeNgQAktLMaoLzDT4la5+gFL6IIOI6+PASmSNCHCNnUf7CStobpyF0RVZsdDjOFqRHOg97 X-Received: by 2002:a05:6808:19a5:b0:3b8:5dd0:8ea with SMTP id bj37-20020a05680819a500b003b85dd008eamr20821257oib.9.1701307994931; Wed, 29 Nov 2023 17:33:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701307994; cv=none; d=google.com; s=arc-20160816; b=Fb6WrYAx3uLmYcr9ArQSxowTrwJEUFQJ0DYQ+GUPg2dtmNtN3PgOw5/KYpl94JaW20 yvRbmpON6ANKDIVFHiP6YdSoXR3wkIjHqcIgGbn7INfhGgUYw9hmrSQml8ejRActx++X 75ceRvdsGOLj8K52lbNnAn6YZp2M64Q8anP6ai4ExQHFZXOBZbWeboNpteZUs4DHSzO+ 3pOMr4h8Usi452Y43kPfC5T9rGDwR2Awy6LO/j54z0icfA0yn/WGJoZYWxL4O6X8ha+z yw0vp2Xz5SjD2YcLHiDZj7SuNxmzqht2VSr076YXr2BDlbvbPegGu0jKlT0QkcEssNJI +Wdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=qF3sGB6SkoVg0qyY40kKytZDE6Xqtf4QpUkuuerWAGg=; fh=GZbsnpAEnp+pJCwMMV4zhLpa3Ei2NcTeFazlN5YjFhY=; b=lFG7Aye3eSZTlhcKBXJvUdKwhlo43S8sArPV/oWKLn6y1plXxnpP+nl3iw5eT3J4Qb gpj3fhuWu5aZY/nyq6J4h47rE4eDdxV2os/Qggf/JWRrfQoQihuW2VGDqmpZ+YAji9e5 loRVAePZhxGbzoblekTmx8E7sEW7JcmqAqrFzx3nUy69143wpXq7DWG0dG+XmMUT6ZJz EWJyfS8kq+awQjodL+FUTnZiU/RftGRemzBFsABcMppW1sqK9M4ho5PiojQ9i8y5c1uY VzzFt1gTgk8hjOf31hXqDUJLLoBungs6Tm2pHl2HoSNbKFPWmgSiPHrS7sXEhtWC7y10 dMDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IE/6iYqx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a1-20020a656041000000b005c2791fedb4si172233pgp.21.2023.11.29.17.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 17:33:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IE/6iYqx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F164C802D234; Wed, 29 Nov 2023 17:33:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344003AbjK3BdA (ORCPT + 99 others); Wed, 29 Nov 2023 20:33:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343996AbjK3Bc7 (ORCPT ); Wed, 29 Nov 2023 20:32:59 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F83C10C3; Wed, 29 Nov 2023 17:33:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701307986; x=1732843986; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=J/LRvfhiMq4LbhQzlNk2y450X4xdxFuUPAYrPIbDPDA=; b=IE/6iYqxSwZvVTlu8EF484WyQ7gNscDRgPvsYxmmEJZXuYtyTLCLhWoP pPS/GzC3qySRGwmZLfpirIr16rRiFf56EKA+1PsdbbnhezbFCcqZWhOvI AA+G2lsO2F8Zm5G3gjMew0etQFjJRks7lz2qf3/6A1me3HM0OjFwCx6Sl wYvDAAn9FbmN06cG7mJHBNpChw27tB6U6ZO/3WpkCa4LfM+IE9nt4GBcx KvGHLzBGJwYqsEl+N5nae64SEP+b/iz8neUujZwlPePttHxUmhEYbDUVG /Iup1u/UR6KBqJ/UU492mayoABEDsf2MCO0/ZHvy1NLsXAiAA9d+l3VC4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="131549" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="131549" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 17:33:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="1016467449" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="1016467449" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.213.173.40]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 17:33:04 -0800 From: Ira Weiny Date: Wed, 29 Nov 2023 17:33:03 -0800 Subject: [PATCH v2 1/2] cxl/cdat: Handle cdat table build errors MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231117-fix-cdat-cs-v2-1-715399976d4d@intel.com> References: <20231117-fix-cdat-cs-v2-0-715399976d4d@intel.com> In-Reply-To: <20231117-fix-cdat-cs-v2-0-715399976d4d@intel.com> To: Jonathan Cameron , Fan Ni Cc: Dave Jiang , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, Ira Weiny , Huai-Cheng Kuo X-Mailer: b4 0.13-dev-c6835 X-Developer-Signature: v=1; a=ed25519-sha256; t=1701307983; l=1103; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=J/LRvfhiMq4LbhQzlNk2y450X4xdxFuUPAYrPIbDPDA=; b=LtEnHMx26EnkkJq65L/SvzLr4Hj3z5Mb8duGdIrZoyJdc/S8OJYd3ZNjfyRpQJeyI4uYzVa2Y A4d5IYEL7RMCh9Rap5TLxg+Fbv7sxnJURcHRY/OAiePYzeUivnJLN9l X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 17:33:13 -0800 (PST) The callback for building CDAT tables may return negative error codes. This was previously unhandled and will result in potentially huge allocations later on in ct3_build_cdat() Detect the negative error code and defer cdat building. Fixes: f5ee7413d592 ("hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange") Cc: Huai-Cheng Kuo Reviewed-by: Dave Jiang Signed-off-by: Ira Weiny --- hw/cxl/cxl-cdat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index 639a2db3e17b..24829cf2428d 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -63,7 +63,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) cdat->built_buf_len = cdat->build_cdat_table(&cdat->built_buf, cdat->private); - if (!cdat->built_buf_len) { + if (cdat->built_buf_len <= 0) { /* Build later as not all data available yet */ cdat->to_update = true; return; -- 2.42.0