Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2801162lqt; Tue, 23 Apr 2024 01:50:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzQXmvH0zJlgbRbTHDGcl1V8N8tLN8VDzq9rbuR/78OjgeDidiEPVqVt2Jx1I/RXiw1m52x+v0EFPZAGzUbT3VOODAP+veKPsHrakReg== X-Google-Smtp-Source: AGHT+IGYfrfLTdcsSdIvWRI3mMjwyVurDiZbkij4mJJzdq2QOvjg/zBoORspHGzoDyU5f63M8rS2 X-Received: by 2002:a19:640e:0:b0:519:6691:4135 with SMTP id y14-20020a19640e000000b0051966914135mr7935560lfb.67.1713862213406; Tue, 23 Apr 2024 01:50:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713862213; cv=pass; d=google.com; s=arc-20160816; b=f6noLKWj8kxNuYSSuq3pXUw/RXo/DDxS/Zar1thqdDT5AqXUNA2ZVTr6uslgNBn+7r LdX7fY7/GqO2Ee+xa7jB8SDls7qxNSTwNlf9YUHISSfm5OwYlUhOV4wC6wH1R4ZcJMz5 PfI9strIL9bjwCdWgzPyyk18nK4By87P/3/bepxwTi1WjHn/CGkDgqRzbX36EYF0Yvvs 6vEuVB/HjaofIRPKx+HQe2MP4w1gBU4SWdDRM59Sul1wPRBAjyQMJaAXDPog/Wy6kWRE KDbWDimpIl7IkdTeS2uKRlECl26OQEJztSoBEJJ901ov2zy5OxEDcB9m5NQVnA/yntJi gxNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=L4J7qd/XZ0ypWpp+h5WYJYwKi99NtUfoP7PfThf+OQU=; fh=NtyE8IAZbPYmQoM0YTKakdo4bopxzYDpc+hhHgw0qco=; b=Mz3Dve3jDBYVYRgApQucPUAsdGAtLFORpFA0UlJpGsiY3k5HgncXuSZ/xgHD0eZBl6 AeZeJi+APcN8htFh9SuXG8EEe5oqgfGsCKy3AUJTwKa24TZuJ4sdfmRvn0tqr6JgIRFn db/Ts3/I8zYPJ7yrPT6Lzch1dxWdthtuym9d+XxV+i/OzlEdM5S37OMCDq9PeFJ+kL5e slodt/jeK9voWDOKHcWgqnUetXGW9tH9X19jl4C/UbF7hoxMcuGHI7OJ1AIH4H2fEqsu KIKHU6xFJjMuMfDhxmMWvLpQEVewgLFTPC16KRYZQglYZ+vmhbHAu9FBuiN8rEzrPGP2 GWlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=rUPopUxp; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-154732-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i19-20020a05640242d300b00570241f7504si7300778edc.670.2024.04.23.01.50.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:50:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154732-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=rUPopUxp; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-154732-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1F0541F21AAD for ; Tue, 23 Apr 2024 08:50:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D89E85B1FB; Tue, 23 Apr 2024 08:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="rUPopUxp" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B33A5320E; Tue, 23 Apr 2024 08:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713862174; cv=none; b=EGAVaqx0aLoNCjex2hQq1twOQBzKgaRsNwjo10/3FmeSAVDKI/HAxoi2EO7L/8fVwAIHcirC4YE4QAE/ZQISIbFzCzEVmlkC3QKnZhBTcatWyrLKUcS3ulm6QBlddMIrqafnd3H1jqNHsoqXUUs/UFJ4tQbgdetgPavubmhaa2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713862174; c=relaxed/simple; bh=6/vUskkjXBSmbcUaFdA4C9ObD9hupo6oExR69oZ9qF8=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=onDZFtaTk5oieucO6C7FJh/HE931JBqcC9mxHzA4YxkzhCIfJi01nhsn7IrRKwiE1Kk2x4eCffrQYGsF0UnZRQTd+PP4PsirqKWlQh4bI6OckDccq0F7mZMkRgg6CG0lgAHFkqrd+6mFFi//EqkQQcSkjkx1eKtyWM59pejgJOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=rUPopUxp; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713862171; bh=6/vUskkjXBSmbcUaFdA4C9ObD9hupo6oExR69oZ9qF8=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=rUPopUxpix3KnYCdyuoaaaVitsuJiQdIMSsjqZ4ViiKs+AvYkESibS7Lt6Twd1Knp KtEIQp/Lw/DW49tq7SQW9HevBvkym+ZCgGbri9faDSNDGIAimnkYM2llcXDan4nFbg CB1S1aFVOIW07tsXlDNWs5uEcI+NTXlxmkFwNnat5g8Wcfp5QjEFHksH3GGXU8rI0o dRr0bnYWGpuVYLJXsxYraja73NZ5jBw56d0bfSOwRsXgDgdpTjgsHkxa6N7TPckAKX Oz2N7/TwuD+fMRiCYU2BC9hFElcyRgvj4Fe9Cx5PNLpY4hUcUpbQYq7311FwVGj3tX KfQGOK5Ap0AHg== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 7F4593781183; Tue, 23 Apr 2024 08:49:27 +0000 (UTC) Message-ID: <981053d8-c67a-4958-9016-5f19c7884459@collabora.com> Date: Tue, 23 Apr 2024 13:50:01 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: selftests: Add 'malloc' failure check in config_name To: Kunwu Chan , kunwu.chan@hotmail.com, pbonzini@redhat.com, shuah@kernel.org References: <20240423073721.2001016-1-chentao@kylinos.cn> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240423073721.2001016-1-chentao@kylinos.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/23/24 12:37 PM, Kunwu Chan wrote: > There is a 'malloc' call in config_name function, which can > be unsuccessful. This patch will add the malloc failure checking > to avoid possible null dereference and give more information > about test fail reasons. > > Signed-off-by: Kunwu Chan LGTM Reviewed-by: Muhammad Usama Anjum > --- > tools/testing/selftests/kvm/get-reg-list.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index 91f05f78e824..22398696ffd6 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -66,6 +66,7 @@ static const char *config_name(struct vcpu_reg_list *c) > len += strlen(s->name) + 1; > > c->name = malloc(len); > + TEST_ASSERT(c->name, "-ENOMEM when allocating config name"); > > len = 0; > for_each_sublist(c, s) { -- BR, Muhammad Usama Anjum