Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp174968rdb; Sun, 21 Jan 2024 23:49:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFM5hdHcxICw3/jMCQbn82QsuC5jyGveXO8f7D5sDZ5YZOhAlhBqKGsp9tVGpr2g8khXcZT X-Received: by 2002:a17:902:7c0b:b0:1d7:4dfa:cbbc with SMTP id x11-20020a1709027c0b00b001d74dfacbbcmr630957pll.100.1705909797875; Sun, 21 Jan 2024 23:49:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705909797; cv=pass; d=google.com; s=arc-20160816; b=hOXg1l0xzSMqUJeO+76O2RTAzV4WyScA5eKO4Au5cPk3UJYkl4aDy15AFFqrTlevlw XeBZuyfqQsjByy/yVNI+z9ZD2eIY2sLHwwXsYM55Y2J2C6yplKFeW9JDO2uPbN8V5rrX /i/H+K58yetkmJEf0VUkulcCAO9TSBZI027JWj/fnUSaLhoFKS0XfyKJW6sWZXQ1Qf7C v2ASgG3Yu0KcN+bSuhG5kPwDG1/yALsVIqi7QFqQKfz92NbWmcWuVbzdhxyKPXt6tZbB m4m4LCQmpuqhb8+XAk7TB/nGKnSJL5bJ0qXCfP9wi0ixjhtM2oXF6DaatFBtV/4J4hWv BT7A== 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:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Mqx8VoqXZNNLcXCtFG4wPJRFyC6nW6vjKwJ+wnWR+fY=; fh=8+YaXINFCYEDY3g4Vw3LLNdbz8YV6aYfbBoTW1disZg=; b=A84y4fJqBxCs3O6yJ2e4foZL63HtPiLX2KQqg7ZlceI4gFwlb1UbxjzF2Mj0xbc9G6 lBE1XyG5S+paTOQyUFBc//PbTPH9bFhTCjnQmehe2lKM6HlNibcJ4m00sxk7Vc74L5V0 uVDdSF888ZgrVjDEI4Use5Y2is52tkBRvoFGahUbPkEIMJScQDJ/U786NTNXBcwUxGcS Lo2lBkb+KKsKKiYgFS24cYH/D9WAb707SxmuGhE04BljnHpnB4rflik9hPwGObeTBSa0 iYmSKfAeBC+dfRYBrTBr0uD5VN+lfwj5cuE54r9Lp3BzRpC7WCSeQ3zUB5ec8SFV6pek l7Vg== 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-32462-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32462-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i18-20020a170902c95200b001d75b1d55d0si747912pla.286.2024.01.21.23.49.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:49:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32462-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-32462-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32462-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1311A284C46 for ; Mon, 22 Jan 2024 07:48:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CC4C18AF1; Mon, 22 Jan 2024 07:47:25 +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 56DD217BDB; Mon, 22 Jan 2024 07:47:20 +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=1705909644; cv=none; b=rt/OCWpt6bRbOOvTS1af7ZmYenbYCkycwrRB3NDOf+Ias4ddCqie4faRm4J+uKRJfqtoW7n5kIzj9zxouUZUOh6jTo62YYOOCpnW7bUk1XGXKWl3X7nC5DazJDhFaOeuktu3LmwpBPfJRn7w+G02W1bqKmuItMCdZDHbVuIpKWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705909644; c=relaxed/simple; bh=Uv+psVs71l3mYBTEtoJ9zpYjshD94k7VzSuOI7ZEPY8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iHA/WrxIV+5A2cZTjcnGOW+yo3eeqPCyh1DL6v3lYdIYaT8o+MirBWforJWCYrPqBjIa1p0pKQ3JEGUVE4Z+DZ2FIGRImjBRg1ZHSpyqEsaKTNErRG81MbkKP16Jk3nHE7yOw/c+9Oe/9rF2hMosACr9tYtf3BKdycb5m5DF0nw= 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: 565b878a508849b98085f4b287cfd53f-20240122 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:341d19ce-db61-4755-8c58-6ce5c2018139,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-3,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:7 X-CID-INFO: VERSION:1.1.35,REQID:341d19ce-db61-4755-8c58-6ce5c2018139,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-3,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:7 X-CID-META: VersionHash:5d391d7,CLOUDID:6bb26d2f-1ab8-4133-9780-81938111c800,B ulkID:240119184126L868QB56,BulkQuantity:15,Recheck:0,SF:66|38|24|100|19|44 |64|17|101|102,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:40,QS:nil ,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI, TF_CID_SPAM_OBB X-UUID: 565b878a508849b98085f4b287cfd53f-20240122 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 935448798; Mon, 22 Jan 2024 15:47:13 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id EB762E000EB9; Mon, 22 Jan 2024 15:47:12 +0800 (CST) X-ns-mid: postfix-65AE1D80-872727190 Received: from [172.20.15.234] (unknown [172.20.15.234]) by mail.kylinos.cn (NSMail) with ESMTPA id 0A1E9E000EB9; Mon, 22 Jan 2024 15:47:01 +0800 (CST) Message-ID: Date: Mon, 22 Jan 2024 15:47:01 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] x86/xen: Add some null pointer checking to smp.c Content-Language: en-US To: Markus Elfring , xen-devel@lists.xenproject.org, kernel-janitors@vger.kernel.org, Boris Ostrovsky , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Thomas Gleixner , x86@kernel.org Cc: kernel test robot , LKML References: <20240119094948.275390-1-chentao@kylinos.cn> <91af4a8c-d2e2-416f-b02e-5d69553c5998@web.de> From: Kunwu Chan In-Reply-To: <91af4a8c-d2e2-416f-b02e-5d69553c5998@web.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 2024/1/19 18:40, Markus Elfring wrote: >> kasprintf() returns a pointer to dynamically allocated memory >> which can be NULL upon failure. Ensure the allocation was successful >> by checking the pointer validity. > =E2=80=A6 >> --- >> Changes in v3: >> - Remove rc initialization >> - Simply error paths by adding a new label 'fail_mem' > =E2=80=A6 >=20 > I became curious if you would like to simplify further source code plac= es. This function hasn't changed in years, so it's OK for now. >=20 >=20 >> +++ b/arch/x86/xen/smp.c >> @@ -65,6 +65,8 @@ int xen_smp_intr_init(unsigned int cpu) >> char *resched_name, *callfunc_name, *debug_name; >> >> resched_name =3D kasprintf(GFP_KERNEL, "resched%d", cpu); >> + if (!resched_name) >> + goto fail_mem; >=20 > Would you like to add a blank line after such a statement? Sure, I could do it in next patch. >=20 >=20 >> per_cpu(xen_resched_irq, cpu).name =3D resched_name; > =E2=80=A6 >=20 > Please compare with your subsequent suggestion. I=E2=80=99ve seend a reply. >=20 > =E2=80=A6 >> @@ -101,6 +108,9 @@ int xen_smp_intr_init(unsigned int cpu) >> } >> >> callfunc_name =3D kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu); >> + if (!callfunc_name) >> + goto fail_mem; >> + >> per_cpu(xen_callfuncsingle_irq, cpu).name =3D callfunc_name; > =E2=80=A6 >=20 > Regards, > Markus --=20 Thanks, Kunwu