Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp190985rdb; Mon, 22 Jan 2024 00:30:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPaVOSzuL61OnrA1iGSTQuK6yZoy3AvmV+LW+ZeWy+kdCXqsOMq0shTsBCBcRPET/nb4FT X-Received: by 2002:a9d:7652:0:b0:6db:adb6:a857 with SMTP id o18-20020a9d7652000000b006dbadb6a857mr3850702otl.27.1705912223956; Mon, 22 Jan 2024 00:30:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705912223; cv=pass; d=google.com; s=arc-20160816; b=UmEugfmPJx1hCpf3vC4NrgHsc8lJMr+yttTwjl2e3KPwwlMJkfZC0WtC1f6c2wMDOd D4FULXh0C7wQZ7aMbKTT+Sqal7+r3pTl6uc9z/dBl66yQYd60ekX3Ke7QuAVdgiFJ58p x25SbAcaiyEllWzoq57D6a8bVxyu+0ixU96XSAHavP5QB2F7NzeLnwBV3AiyDeC1fRta xdr1ShBcfFpBInU1f7oVrJfZgKWExUAOWmKk6xRKGOXmdkUCE65De+9Nb2jWWXCksBCb 5Uzv0YUgeIa1X53rVj7KDhjhFvMF8upyYYkaPqvzNyb+YyFbxkLYCB2lyj5Ix/EJnCpI fNgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SFCiLnY6xBPrqdHIolQZod6apPlIVJ6Tq13E5RZi33g=; fh=oYW7bWkHcZ1AMpeNVAdx5XkYYoSvTlGHsbu2YuovbzQ=; b=H7E1XOUx9qa47uRAkSIyezz9HAGCbSsQ7zpyK2rDgvWbwxD0EBc8YwQ+63ejfAwHUf mo83QfKSe+8k1yB8+d3UoMQkArV+dYUwkGY2xUcz39FfI2ICEGZ4XAnlBfkl16E/APFy WQG9/WexCtAKQwwsqwlt79+x4kofUSrO4i7TGFXSggg3WuVvG7Ij2ulsvjRKC2GBZTCC JCDEKSzNSgAjypSiH9sX50fZ2U7WKsomGVrYYALD43oXWvmr8VKZp97uL5P7RPWw73Hw CVZYtPLFv0HiQFlyvUkuZiWMJa+C3/uaO1p5XbRKg2V52LkavZsJYHGcNS6/65V4ta6L E8nQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDQ2aEWv; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-32519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p7-20020a05622a00c700b0042a3971a788si2790982qtw.29.2024.01.22.00.30.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 00:30:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDQ2aEWv; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-32519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A31331C21042 for ; Mon, 22 Jan 2024 08:30:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12AC6210FE; Mon, 22 Jan 2024 08:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZDQ2aEWv" Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BB1E18C20 for ; Mon, 22 Jan 2024 08:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705912209; cv=none; b=MpKlXwtbGmZDvYcHwiP4fXsvej/32FY1kw0wWwqZglBsCeC2Cq+85pb7O3310aJN8UZyYOyqHFmo3IlSLJGz26ukPVA7vR5ttzEY5p2+jywPsl9stERg1htMxZ5bNTLktBx8q985b+IL2+h+rYaxewBqPx+q3Tz9JcsTwTBvjNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705912209; c=relaxed/simple; bh=pMUV4op1QVmaWaTXq7UmoOws2OnRP5AvymPcOZREQRM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NrSkJaZDot22deW/pwv0X1lcsXwKpZUfdYX4xc4TTyFd/l//cwImF/3dG5+HfH9Cj5OWDoCVkei54lY5jnnNKyAr60nc82+0cNaPHSeflYhZWqlaPo1ios8n8qo/4jaWbQFYhwwBBwUeFVFOAQqEiRFn1HIXEUeim+9Yft85zqw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ZDQ2aEWv; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-338aca547d9so2253353f8f.0 for ; Mon, 22 Jan 2024 00:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705912206; x=1706517006; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=SFCiLnY6xBPrqdHIolQZod6apPlIVJ6Tq13E5RZi33g=; b=ZDQ2aEWvgcLL3mtV6o2Rv4sEmLDjBkBQHtjN+PMeI9eHXU9jVtTVyIWe/B/V8cFlNP T0sOUoAxILun50TTK8as3sRruvPmlNPc+oN4lj5P7jqqX3pBgcMjgaFLLClNFwKsJjgG Fi0YXidBTxa5HbaDQPRhnHk20gtf3tZ4+18kcPElMKYQ8/mmXw96oc3qYsS2ET6XJyq+ 1lc7/5KZ/UnRhntfbBQyV5qXLEADRpQBiln5AM7Br4OY3+wsqLsO+cJbaHPIwlBHlRNN PiGYO0j+2YeEil7DJxawzBea3kiJtAVmVSo0ORWtc3rejbc6nk/d/mZKZ9LOrDGiAwBs QU8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705912206; x=1706517006; h=in-reply-to:content-transfer-encoding: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=SFCiLnY6xBPrqdHIolQZod6apPlIVJ6Tq13E5RZi33g=; b=BVUQ/XvdtQf0eHTWM485O6vHeHCw4/53CRWLl8lUGvEIltymebcrLbWiNxUXN1dy51 4dmO3QmiTt57ZuPwoWOborJCBhFVy1vzk3Y8iYY5cfnqO1YXGyVFCVwUv9xLQT8F4h6L ixhaDc6VqtCdpDNbJZ0AqAtoR2NboaPYqsmVCeUEZodHYTpRH2UojMdOhZhNIjHoeK55 sYO1YWIkdvc/rm1im2ITRN+TNZU2KQmIrBt6xv2FjjmBsZp+7eQym6GdsYp0MAYKn1Fq aJNsUBZVM68O1SQ+eXsPNGUET45LdL4Xm2dQhtk2ymks75euCWnSS/FDN/oJHgojIY94 tkQg== X-Gm-Message-State: AOJu0YyJiko3/rG4yJ93EUrqI2xFOGQLRbuOWXuEmUIQLmu/25IWN2UH wxQeEJ5GMgpwP01dAotAwXRie3Or9SJ0FVdN4dHwey0Y8+WwEor+RFsY0mdJEso= X-Received: by 2002:adf:a18a:0:b0:337:828b:dd72 with SMTP id u10-20020adfa18a000000b00337828bdd72mr907642wru.55.1705912205784; Mon, 22 Jan 2024 00:30:05 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id d21-20020adfa355000000b003392a486758sm5511850wrb.99.2024.01.22.00.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 00:30:05 -0800 (PST) Date: Mon, 22 Jan 2024 11:30:02 +0300 From: Dan Carpenter To: Kunwu Chan 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 , =?iso-8859-1?Q?J=FCrgen_Gro=DF?= , Thomas Gleixner , x86@kernel.org Subject: Re: [PATCH v2] x86/xen: Add some null pointer checking to smp.c Message-ID: References: <20240117090018.152031-1-chentao@kylinos.cn> <1705655941162581.825.seg@mailgw> <517fae75-c4e7-4576-81ff-6a14a3eb9cd7@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <517fae75-c4e7-4576-81ff-6a14a3eb9cd7@kylinos.cn> 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. > > … > > > +++ 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 = 0; > > > > I find the indication of a successful function execution sufficient by > > the statement “return 0;” 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. This advice is good. Don't do unnecessary assignments. > > > > > > > char *resched_name, *callfunc_name, *debug_name; > > > > > > resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu); > > > + if (!resched_name) { > > > + rc = -ENOMEM; > > > + goto fail; > > > + } > > > per_cpu(xen_resched_irq, cpu).name = resched_name; > > > rc = 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 statements > > for this purpose. > > How do you think about to use another label like “e_nomem”? > I'll add a new label to simply the code. 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=Elfring Perhaps wait for feedback from the maintainers for how to proceed? regards, dan carpenter