Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2773785lqt; Tue, 23 Apr 2024 00:37:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdMTlGBRlb71q7Qa7QQ0GFL43tvgBRYw6+U4b1LHbLiEj2t7GCVO0ZAzYB56n/c4YBU+DjqaucdWCQUHfks9A/0uWajSM0wcaSLmQL6Q== X-Google-Smtp-Source: AGHT+IHmjdDLEsZTW1NcVb7u4VvHu8mCi10dccFDuIoWSFgCm4O0eEn0E0VvG657katEyum4v8F+ X-Received: by 2002:a50:d716:0:b0:570:d50:e7d8 with SMTP id t22-20020a50d716000000b005700d50e7d8mr7852039edi.22.1713857871253; Tue, 23 Apr 2024 00:37:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713857871; cv=pass; d=google.com; s=arc-20160816; b=paMJR5Jd2UWaF4DHhAjlS38Hq/vWBVQjqMGMUlrVW0zyss6cZnNuDzT2ETBfpQnSVj 1tKitFIVRNn0CgvlkYepmxj6oBr4FSbJbG3GP0wupAr5f9mH+XvW/+lG7ZWFWHxPvcak yVgjICJsj5taqfA4E/YPZzCIwv41ExetjJmNHZKUJZxmKPU5iCSswFSRjc2JCOvMYmIw aH48T32XXSQv0ks9lEQu7SCxn0X6UWb3Y4agIDcovRzL+mZDfyeRs595+jIdv0uFOvSw N8WbOk8XFYM+OoOawotcK/19IF+SyttkXT4lmjXL44OS7Qr6rGDcua1fQ4sSNsy5q4qI 0Wdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=8GF9LnO1F/xVoCzBt5kPAq5+xd933da5iQ7NFbVX9ro=; fh=zRWgyJpflWbxm5mX9wg/iIrHVNHwaH9wIws8BzVt44Y=; b=FpDn5NWCANovJm4OPVGQgOI3UzrKpAFUbyp2lsmMXA3GDGQYvp9lnBB2AwZM2q8EJn BuQSzGi9eIDECx7f0mLbRn4P5hcKwd/lHovMiupsd6VSW9DBORqoomcMhPA1VIrMs9IQ DZjsaTLlOXklnfaCw0obYtV8CA2sbI8uMK/yxBSb7XauhK5qmv1OQMdt98blgRt6gPhB LWRTGOx8TzKdoT/8g1iXdjitbz/1L+5e8X1izlTi/ivFQxH3ybw1gn0SxmuRX9QKqnaK 7RDhyfHFfO8AuXRWxZO5EB8mTD5Nn49MLGsL3Yy6aggbhTCV+5l8c7twgPJ/Wl9PHIln 9K7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-154611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154611-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v15-20020aa7d64f000000b005700360750bsi6851931edr.297.2024.04.23.00.37.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 00:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154611-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; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-154611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154611-linux.lists.archive=gmail.com@vger.kernel.org" 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 E24441F21D2F for ; Tue, 23 Apr 2024 07:37:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D0A947F64; Tue, 23 Apr 2024 07:37:41 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 9D6B147772; Tue, 23 Apr 2024 07:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713857861; cv=none; b=af8QeoZcAuyjtIw2DzBipd8qpGG3A6lfxLCKw910ns5I5Qzss5b0O3+TLE/bwYsT3Kh7xFcw4qWF8hhO93bOMTU0sjlMCLstcx9Vr/eWotGIYJFMJc7knMdVcnXhvcOV9pn+bqsL2sTPA9kM3JYBYLxAVmj++5eJJGe9HsXpIR4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713857861; c=relaxed/simple; bh=xy1GcLvjBjJXjiL/7OVsqPvJYIeiFhB5hYNxFZjPnY8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=pqEKpSmAlKaJ/XubgGfmlnNnuR7nVe6/5ar98xjpV1EpaCnFozP71RWjZEtJ9dxyDD8KOe/W/qOHFyJ9ai03TbWikwSNh3qF60roJriXjscmqBMgs2zl/Ad4vMHIejp/sFlGuXUz4zTiEXDhNuc0bklql2dbYjSqJ4aLyvV2bJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 54a3e73a014411ef9305a59a3cc225df-20240423 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:5c1badbe-41c9-45d4-b027-0d1082d0c4ae,IP:20, URL:0,TC:0,Content:-5,EDM:-30,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-14 X-CID-INFO: VERSION:1.1.37,REQID:5c1badbe-41c9-45d4-b027-0d1082d0c4ae,IP:20,UR L:0,TC:0,Content:-5,EDM:-30,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-14 X-CID-META: VersionHash:6f543d0,CLOUDID:78bbcd68642dc5561833052310f5a086,BulkI D:240423153729G2ISWZO1,BulkQuantity:0,Recheck:0,SF:43|74|66|38|24|72|19|10 2,TC:nil,Content:0,EDM:2,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:n il,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 54a3e73a014411ef9305a59a3cc225df-20240423 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 942058463; Tue, 23 Apr 2024 15:37:26 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id D5712E000EB9; Tue, 23 Apr 2024 15:37:25 +0800 (CST) X-ns-mid: postfix-66276535-657266450 Received: from kernel.. (unknown [10.42.12.206]) by mail.kylinos.cn (NSMail) with ESMTPA id 235EEE000EB9; Tue, 23 Apr 2024 15:37:25 +0800 (CST) From: Kunwu Chan To: kunwu.chan@hotmail.com, pbonzini@redhat.com, shuah@kernel.org Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH] KVM: selftests: Add 'malloc' failure check in config_name Date: Tue, 23 Apr 2024 15:37:21 +0800 Message-Id: <20240423073721.2001016-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- 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/s= elftests/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 +=3D strlen(s->name) + 1; =20 c->name =3D malloc(len); + TEST_ASSERT(c->name, "-ENOMEM when allocating config name"); =20 len =3D 0; for_each_sublist(c, s) { --=20 2.40.1