From nobody Tue Nov 26 12:25:01 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1707909609; cv=none; d=zohomail.com; s=zohoarc; b=jvzRJ3ybmsS/huqoWuQg2LnK19wbhblLorcjTsLdxxb/T8gqiCKHWht6JEBZLbX18gfA+wq8q+xk7SD/RSu56+esMah4LDj1LUpqZ30Nl4R34M8MOJpH9jwJht00q1D4rkAHd/YODaJBtKEtcc3IPLcTv29MC6BjwOLXDVgX0EI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707909609; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0BqA9eVzG1Xkbf5+yaBkWiX1PEZkTb1figaBuHZ4bdw=; b=hm2RJ7f1sztMPgAVdGGr5YnLOIwyIxWen7bptyFPFtWdr8DtewB0KnIUp9YoS7bToMga1atFi4BOdOtba2JV+wOKoQZDdZqXG8PqCxvTi3f0Gn/HoP66H0BqT7KMGgDz0KQ5fErHzY71Kba5ccffGCjTh4fD49tqNsnsbOtO/Ao= 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 1707909609934817.3497007467743; Wed, 14 Feb 2024 03:20:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFL-0005Y6-Jg; Wed, 14 Feb 2024 06:16:11 -0500 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 1raDEZ-00045y-7i for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEX-0007Dc-3n for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:22 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-As1qIUyQO_yArAJM5GL5bQ-1; Wed, 14 Feb 2024 06:15:18 -0500 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3c3f477eb7so186335466b.0 for ; Wed, 14 Feb 2024 03:15:18 -0800 (PST) Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vh2-20020a170907d38200b00a3d08f3283fsm1468213ejc.104.2024.02.14.03.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909319; 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: in-reply-to:in-reply-to:references:references; bh=0BqA9eVzG1Xkbf5+yaBkWiX1PEZkTb1figaBuHZ4bdw=; b=DX1g3RD274lCMog3k0Rn59cqrgFo54lofITPZof8xT0D92jT829dyvOttz1YCkPFCDyLeb z6/tn4tCUTgDfwsQuWdTXcsmU1QY5b1ieQNCBhkZjt2+y2BCrLhl9cqt1O+tae7GjoSPGF 9rSAiGigbsxR0a5a2rWxodNIhVT+Y50= X-MC-Unique: As1qIUyQO_yArAJM5GL5bQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909316; x=1708514116; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0BqA9eVzG1Xkbf5+yaBkWiX1PEZkTb1figaBuHZ4bdw=; b=PEAzAWIunbKynyLHgIfTWGTKR9yDIUh4s7SyWt+libFQkGG4PfN2K11cRs2OK2vjdh h2Wb699fUK9l5sUuIZTBwb4Brk2yxcSpYDels7+HHZTFZ92qV56znphnhlyF/Z9/F2N2 7bgI2ivoS9YbHt9BZjAx/Gpi4zZ/BDw+M8iJrcQBPG03K6GC+0D0Gfziv0ZhI+C5tub4 DAARB1XL65MTYS/VC5Gx/g2MFKHvswaecqmDwH6MDKM4xEwqwJCswKWNucCEc6qugzHH /M03A0b2nel97cM6CK6w9ZfcNkUIgEm5CsOfiXZW8xqKNlkakEfsonZGmSiXgypSDB7M yzUg== X-Gm-Message-State: AOJu0Yx7moXpQcjtR8xkBo2BjGfujOlkoDZRNJSiQQoo2KhtTUdDH/AP k0YQwxbao+hBDNVB0eggMtG5N+2PcDdu1rQ3HRmGi3Ve3CEXWRfU9RN3ZWAAyDIYxwoWiKplDKv sGwjqTUH8xAmKC8IKhS4aokkFm+6QlR5i/XFJsycf91+7CV5BrgeKfhWUyEntVk73D+CSyOI0Nj IWOXys+mlJ1OfVgxfgzDB5GKGNj+NVBQ== X-Received: by 2002:a17:906:374a:b0:a3d:2637:b713 with SMTP id e10-20020a170906374a00b00a3d2637b713mr1776481ejc.54.1707909316224; Wed, 14 Feb 2024 03:15:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEg06sXqD5nwQvc3dSZ5KvqlW8ZAzu7nOBsNTYs+thJjIcP8XoFHlQhyGB5iiEJARiz3DUKSg== X-Received: by 2002:a17:906:374a:b0:a3d:2637:b713 with SMTP id e10-20020a170906374a00b00a3d2637b713mr1776465ejc.54.1707909315943; Wed, 14 Feb 2024 03:15:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWBE1DUo6l7tRnad2agKVEalLFoCR/WAO8+miM9Eth4zslkepjY7bsAmGGHOYRoZp+NJqGddC0i3dOWnLhOfrDyXwgo0q9xlOSJjAS6TGaKO/NaGDw0PoM82wbiYJTYqQ== Date: Wed, 14 Feb 2024 06:15:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 38/60] hw/mem/cxl_type3: Drop handling of failure of g_malloc0() and g_malloc() Message-ID: <0dbcc0ce2f7b7a98a11224add69b2f2f2b8125da.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1707909610296100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron As g_malloc0/g_malloc() will just exit QEMU on failure there is no point in checking for it failing. Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 52 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 52647b4ac7..1b92a065a3 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -42,9 +42,9 @@ enum { CT3_CDAT_NUM_ENTRIES }; =20 -static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, - int dsmad_handle, MemoryRegion *m= r, - bool is_pmem, uint64_t dpa_base) +static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, + int dsmad_handle, MemoryRegion *= mr, + bool is_pmem, uint64_t dpa_base) { g_autofree CDATDsmas *dsmas =3D NULL; g_autofree CDATDslbis *dslbis0 =3D NULL; @@ -54,9 +54,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **= cdat_table, g_autofree CDATDsemts *dsemts =3D NULL; =20 dsmas =3D g_malloc(sizeof(*dsmas)); - if (!dsmas) { - return -ENOMEM; - } *dsmas =3D (CDATDsmas) { .header =3D { .type =3D CDAT_TYPE_DSMAS, @@ -70,9 +67,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **= cdat_table, =20 /* For now, no memory side cache, plausiblish numbers */ dslbis0 =3D g_malloc(sizeof(*dslbis0)); - if (!dslbis0) { - return -ENOMEM; - } *dslbis0 =3D (CDATDslbis) { .header =3D { .type =3D CDAT_TYPE_DSLBIS, @@ -86,9 +80,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **= cdat_table, }; =20 dslbis1 =3D g_malloc(sizeof(*dslbis1)); - if (!dslbis1) { - return -ENOMEM; - } *dslbis1 =3D (CDATDslbis) { .header =3D { .type =3D CDAT_TYPE_DSLBIS, @@ -102,9 +93,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader *= *cdat_table, }; =20 dslbis2 =3D g_malloc(sizeof(*dslbis2)); - if (!dslbis2) { - return -ENOMEM; - } *dslbis2 =3D (CDATDslbis) { .header =3D { .type =3D CDAT_TYPE_DSLBIS, @@ -118,9 +106,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader = **cdat_table, }; =20 dslbis3 =3D g_malloc(sizeof(*dslbis3)); - if (!dslbis3) { - return -ENOMEM; - } *dslbis3 =3D (CDATDslbis) { .header =3D { .type =3D CDAT_TYPE_DSLBIS, @@ -134,9 +119,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader = **cdat_table, }; =20 dsemts =3D g_malloc(sizeof(*dsemts)); - if (!dsemts) { - return -ENOMEM; - } *dsemts =3D (CDATDsemts) { .header =3D { .type =3D CDAT_TYPE_DSEMTS, @@ -159,8 +141,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader = **cdat_table, cdat_table[CT3_CDAT_DSLBIS2] =3D g_steal_pointer(&dslbis2); cdat_table[CT3_CDAT_DSLBIS3] =3D g_steal_pointer(&dslbis3); cdat_table[CT3_CDAT_DSEMTS] =3D g_steal_pointer(&dsemts); - - return 0; } =20 static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) @@ -171,7 +151,6 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_t= able, void *priv) int dsmad_handle =3D 0; int cur_ent =3D 0; int len =3D 0; - int rc, i; =20 if (!ct3d->hostpmem && !ct3d->hostvmem) { return 0; @@ -194,27 +173,18 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat= _table, void *priv) } =20 table =3D g_malloc0(len * sizeof(*table)); - if (!table) { - return -ENOMEM; - } =20 /* Now fill them in */ if (volatile_mr) { - rc =3D ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volati= le_mr, - false, 0); - if (rc < 0) { - return rc; - } + ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volatile_mr, + false, 0); cur_ent =3D CT3_CDAT_NUM_ENTRIES; } =20 if (nonvolatile_mr) { uint64_t base =3D volatile_mr ? memory_region_size(volatile_mr) : = 0; - rc =3D ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_hand= le++, - nonvolatile_mr, true, base); - if (rc < 0) { - goto error_cleanup; - } + ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, + nonvolatile_mr, true, base); cur_ent +=3D CT3_CDAT_NUM_ENTRIES; } assert(len =3D=3D cur_ent); @@ -222,11 +192,6 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_= table, void *priv) *cdat_table =3D g_steal_pointer(&table); =20 return len; -error_cleanup: - for (i =3D 0; i < cur_ent; i++) { - g_free(table[i]); - } - return rc; } =20 static void ct3_free_cdat_table(CDATSubHeader **cdat_table, int num, void = *priv) @@ -1168,9 +1133,6 @@ void qmp_cxl_inject_uncorrectable_errors(const char *= path, } =20 cxl_err =3D g_malloc0(sizeof(*cxl_err)); - if (!cxl_err) { - return; - } =20 cxl_err->type =3D cxl_err_code; while (header && header_count < 32) { --=20 MST