Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp195921rdb; Mon, 22 Jan 2024 00:41:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTgefj9N+PtMalrIr7KjXM5PL27o9WT/NJw6EWguKq0DqLjzcE770cHpU0h9ZHsEZt++nm X-Received: by 2002:aa7:d486:0:b0:55c:29a:fc3f with SMTP id b6-20020aa7d486000000b0055c029afc3fmr1411890edr.0.1705912915959; Mon, 22 Jan 2024 00:41:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705912915; cv=pass; d=google.com; s=arc-20160816; b=VobLwXoDMYrfuaknRBXaz1Y3QyiEYyrTUU02a2Mp/ha9pr6Wp7b6YZ3w7JbGVRhlHb hdQ2UU7p5odP/Jn7hOI1a7oOut+HzGtQzuTLkCsQc4zmeuM5V0+gUMzAJpZIzpsOV7+c l5MBVDlv0fSGk8lcESwMtMfVY4Pzbl3B41XcNjwaL/wp6W2cJYHOJe7MhvLYtVAG8mBN 14HhG2czPx49wxI0NX2UTZfOMJKM87FmGjtkQL5FfuX1LNoGIBhOUqDxSWukaejRyq1h xiYPKXGHWgi5wSkiqYFCRiVWEKz40EoVBj3N7He3MmrKByPNkuUWBizolgGNYGNuyZ+9 yBzg== 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=P2n4zTzGILURgoUKisy41cq4oijlj+0JFK3KQeal8x0=; fh=s0s3uvOIO5hRFQUM9yI5fkdFZahIpsbOYnkz0VFw33o=; b=X/XYPRkbSyt/KDFvx/CMy8SuP5JrFjVjQ+74j7PMtH/bSod0p5Bgqwae/pcKc4cB4Z 9wsAvdFW28DZ2XkI9zTaqljS5fx57T4R/3Szwaow+VZZ2v0bvDmwdUzcXE10lAobh3jN LEaEh1/ksUD3QXVF6s7msHHJJvX8xQgJFTithovMSSPWb6KvPja4ScTmRzUSFjp7UgNR O8cXqLV87Q3YWtZj/LNuS1a6fr9zSFWPu3KNuULFPJKxgw51mDa2okE3jN2kXxhgTlSt nmmvSSkPPyadtwIjujEaV5qGJM7glmykxNM6TuOA6fONH7per4ErxklLfjhPsj0/KOYC eVdQ== 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-32538-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32538-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 fj9-20020a0564022b8900b00559cbe24779si5981634edb.675.2024.01.22.00.41.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 00:41:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32538-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-32538-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32538-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 845491F23B02 for ; Mon, 22 Jan 2024 08:41:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46DF6364A0; Mon, 22 Jan 2024 08:41:29 +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 7269C21350; Mon, 22 Jan 2024 08:41:22 +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=1705912888; cv=none; b=eTF1OKKkEDr0yl8dn3JFXf4tewOa5mnLiUj+6aavWN3Fr+vIbIamIjl/Wa5dxjv9HnDR4nNVpG5rA/lsXANZtjUKLKzq0aizV5Mtsbhxj7gsebM25TIf3JNko4xZDjrNrPHyxZS0JwKSJ6GmKOfzhP9nYjRvJBtfo/1wfM2ESYg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705912888; c=relaxed/simple; bh=ctuCC6ALFN33W1D3yQUnrYtqv9x78RMPK2D2cHZUDMI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TITRaHrQK6jdW9YZgfj4mgmjsGbzVFJl6u4/ccUBnpT04C9NFVieZwgVHsZevAPizEkdAAd0+5UGgm/ak7c7PY6CEVkiqEYGqQH5mehNPgkyf9tFmaHBrh23FY7hnnvbFvrzBo3OW6mq2OHE/tqbWWZLCGgtFeu7cDw2D7i6IsQ= 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: d1c2b83a7e904730825e5b96ad735542-20240122 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:1c271f4d-649e-4a00-a195-b02e349e0fd6,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:1c271f4d-649e-4a00-a195-b02e349e0fd6,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:aa021d83-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:240122163022SO5X7JXR,BulkQuantity:4,Recheck:0,SF:64|66|24|100|17|19| 44|101|102,TC:nil,Content:0,EDM:-3,IP:-2,URL:1,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_ULS X-UUID: d1c2b83a7e904730825e5b96ad735542-20240122 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 292773570; Mon, 22 Jan 2024 16:41:16 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 864D4E000EB9; Mon, 22 Jan 2024 16:41:16 +0800 (CST) X-ns-mid: postfix-65AE2A2C-464608384 Received: from [172.20.15.234] (unknown [172.20.15.234]) by mail.kylinos.cn (NSMail) with ESMTPA id 3F59DE000EB9; Mon, 22 Jan 2024 16:41:14 +0800 (CST) Message-ID: <39c6bc5c-8c91-4c91-a694-e27fa435f082@kylinos.cn> Date: Mon, 22 Jan 2024 16:41:14 +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 v2] x86/xen: Add some null pointer checking to smp.c Content-Language: en-US To: Dan Carpenter Cc: Markus Elfring , xen-devel@lists.xenproject.org, kernel-janitors@vger.kernel.org, LKML , kernel test robot , Boris Ostrovsky , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Thomas Gleixner , x86@kernel.org References: <20240117090018.152031-1-chentao@kylinos.cn> <1705655941162581.825.seg@mailgw> <517fae75-c4e7-4576-81ff-6a14a3eb9cd7@kylinos.cn> From: Kunwu Chan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 2024/1/22 16:30, Dan Carpenter wrote: > On Fri, Jan 19, 2024 at 05:22:25PM +0800, Kunwu Chan wrote: >> On 2024/1/17 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 >>>> +++ b/arch/x86/xen/smp.c >>>> @@ -61,10 +61,14 @@ void xen_smp_intr_free(unsigned int cpu) >>>> >>>> int xen_smp_intr_init(unsigned int cpu) >>>> { >>>> - int rc; >>>> + int rc =3D 0; >>> >>> I find the indication of a successful function execution sufficient b= y >>> the statement =E2=80=9Creturn 0;=E2=80=9D at the end. >>> How do you think about to omit such an extra variable initialisation? >> Thanks, it's no need now. I'll remove it in v3. >=20 > This advice is good. Don't do unnecessary assignments. Thanks for your suggestions, I'll keep it in mind. >=20 >>> >>> >>>> char *resched_name, *callfunc_name, *debug_name; >>>> >>>> resched_name =3D kasprintf(GFP_KERNEL, "resched%d", cpu); >>>> + if (!resched_name) { >>>> + rc =3D -ENOMEM; >>>> + goto fail; >>>> + } >>>> per_cpu(xen_resched_irq, cpu).name =3D resched_name; >>>> rc =3D bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, >>>> cpu, >>> >>> You propose to apply the same error code in four if branches. >>> I suggest to avoid the specification of duplicate assignment statemen= ts >>> for this purpose. >>> How do you think about to use another label like =E2=80=9Ce_nomem=E2=80= =9D? >> I'll add a new label to simply the code. >=20 > I'm not a Xen maintainer so I can't really comment on their style > choices. However, as one of the kernel-janitors list people, I would > say that not everyone agrees with Markus's style preferences. Markus > was banned from the list for a while, but we unbanned everyone when we > transitioned to the new list infrastructure. Do a search on lore to > find out more. https://lore.kernel.org/all/?q=3DElfring >=20 > Perhaps wait for feedback from the maintainers for how to proceed? OK, I'll wait for the feedback. >=20 > regards, > dan carpenter >=20 --=20 Thanks, Kunwu