Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp533149lqb; Thu, 29 Feb 2024 07:53:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVzbTE1F29x8GxmVq8RopwUPJ0FTVSKy6Lj++9FD1aVptG6nUd9lFBhzSSHW1P3LVw6Pn+8WHDQfGnPjZYEyqDPyyIPTEm6u3UPbwWTgA== X-Google-Smtp-Source: AGHT+IHP5K94uJGqU4A4oddyxWiIFNYAbxC2WnHiWbKUo83yhbwKH4l83RpsdW/WJhuINEwEzN6w X-Received: by 2002:a05:6e02:687:b0:365:1a2f:8271 with SMTP id o7-20020a056e02068700b003651a2f8271mr2817108ils.3.1709222036646; Thu, 29 Feb 2024 07:53:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709222036; cv=pass; d=google.com; s=arc-20160816; b=hIddDHnjvlkEJsfQCw3o6POc46GWow3kduaxXEZenRLeU5Bl5VKVXBRT7LT4ZDru9j Ot4jdRWJ+QdnZ5CtOJxsDYDkqwkXd8Frea9K+ARCR+50lXv0FPqSQe52167hUHEjWwED vFxYBd6VGJkArnu4enF61Azaef5i0EPcDYwR2HOkv0vXn4Oq8SnC1JdN6GMH62kRbnm7 fbmVoGb6ITp9Gv2K8ifBy3Ok8nOe6DpUCYfP4SR9O5VIRNZMvoke8HW+F1Z/pVWI5V0D R4XKkEbIxB7OkG/8+s3K/mm1VgZnm3wKVeRybV7jUe0dC/fZKQQY+88rE823AqBrjzCU 0tMQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FG1sc1Yqp1ir/il7NvjhyMjzJ/AjmzwvtGltqq/iqBo=; fh=dIopZcXZhLJ9jp0q36qSx0Dr5fKgArkShBNvweGfAjA=; b=0FIlsJY5gRyn9LwsAa6arer0P8a0tYMThYpLDYwzUvBAJ5EmkJST3TGat5Qq72LLoJ Ag+teG31xxP0OIH/vtF0xFdKtvSZWn5Tr1SeMLAMquiOrJS3AubnVP36GvEhqQmcWot/ 0gXQNp9ClUnOKv7DoslN2taiElUFFEU6FAkAkiToMoc67oC24PzrDWuhx1KW6lQ00K6Y HtnKA+IWSDSBGgM16amcwTkBWl+1ZiW+rILCTpqU99235RggpPxHDM/pLjREQ2u44IRW fMyC94kFRicrhVXndWNKHphHSVxEDe1v+Z4w/K44pzogj1Aed8IOGMxEts0/iBbtobQw xMdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SYecIYPB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86966-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 j7-20020a654307000000b005dab535faabsi1572210pgq.231.2024.02.29.07.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:53:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86966-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SYecIYPB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86966-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 4EFE8284C44 for ; Thu, 29 Feb 2024 15:53:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97B1215E5A1; Thu, 29 Feb 2024 15:49:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SYecIYPB" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C294914E2C4; Thu, 29 Feb 2024 15:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709221765; cv=none; b=Md17SaS99dU3Ph0Wz/KuH4MPmqPwhKUyODz9ffaMNIs/1OQ5TNzNQoJhFIiFKHENRhXQ1GDXNuLXYS7XogI2+dYTgGVc4MgeNRupw6xgw696z1i0wNVk9Z/9obOOaBQdiWbub5AsTdPA0xcWyO2+Vr7UJo9CF6p324dy43IFksE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709221765; c=relaxed/simple; bh=8b7DfpvkFhJ07ZMBds5WMnK3M2mYX6QhEVWSf43j/K4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nrxmmllV8drqGpmwGCvJHaUN8kBhTXNnRNr9BkmIS554NXTEQ3CTjWRLiU/1JiANSojyOIHgBFXd+ZUbfKIbwbJKnjWC/8PbWNsw+wKZZL9qFaZRaIlozWwfmpmcTn1sgoa8joSWc9KcI/lUiA+hhtw/Cg3i31JNpQoNWXDu2HA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SYecIYPB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23133C433F1; Thu, 29 Feb 2024 15:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709221765; bh=8b7DfpvkFhJ07ZMBds5WMnK3M2mYX6QhEVWSf43j/K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYecIYPBfgm2t/4TqRQUjQnGt/AEfhnkzY1mSZyS5N0p7LilltiLz6j7XWLa6EYU6 6Q/EXXpQIjQ/2K6umnUHKpZ4fBhEX/f7gOdt4VwWiyqG7bmuUc11rh//85GxaSpEe9 XGI9HP1nRlf/Tv+Lm1pjhF/CueR42WLe1j4ke8Y0ip5MzTXrO3fxnZ8pQlj/SSy1AU /38jJoeUyQtc4GhIii9OnetlwuFrJXJA93fXOhxv0DwozOtWvEPfS+EyBxSTBYjqCB PTO+EBasDwL8XREScSOAdfNYy3PIsl6h664qbXmSjJ4KTeCbaMNa+wdWErrpo0PHLz E8GcX21G08GvA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kunwu Chan , kernel test robot , Markus Elfring , Juergen Gross , Sasha Levin , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, xen-devel@lists.xenproject.org Subject: [PATCH AUTOSEL 6.7 18/26] x86/xen: Add some null pointer checking to smp.c Date: Thu, 29 Feb 2024 10:48:37 -0500 Message-ID: <20240229154851.2849367-18-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229154851.2849367-1-sashal@kernel.org> References: <20240229154851.2849367-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.6 Content-Transfer-Encoding: 8bit From: Kunwu Chan [ Upstream commit 3693bb4465e6e32a204a5b86d3ec7e6b9f7e67c2 ] kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity. Signed-off-by: Kunwu Chan Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202401161119.iof6BQsf-lkp@intel.com/ Suggested-by: Markus Elfring Reviewed-by: Juergen Gross Link: https://lore.kernel.org/r/20240119094948.275390-1-chentao@kylinos.cn Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- arch/x86/xen/smp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 4b0d6fff88de5..1fb9a1644d944 100644 --- a/arch/x86/xen/smp.c +++ 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 = kasprintf(GFP_KERNEL, "resched%d", cpu); + if (!resched_name) + goto fail_mem; per_cpu(xen_resched_irq, cpu).name = resched_name; rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, cpu, @@ -77,6 +79,8 @@ int xen_smp_intr_init(unsigned int cpu) per_cpu(xen_resched_irq, cpu).irq = rc; callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu); + if (!callfunc_name) + goto fail_mem; per_cpu(xen_callfunc_irq, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR, cpu, @@ -90,6 +94,9 @@ int xen_smp_intr_init(unsigned int cpu) if (!xen_fifo_events) { debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu); + if (!debug_name) + goto fail_mem; + per_cpu(xen_debug_irq, cpu).name = debug_name; rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt, @@ -101,6 +108,9 @@ int xen_smp_intr_init(unsigned int cpu) } callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu); + if (!callfunc_name) + goto fail_mem; + per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name; rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR, cpu, @@ -114,6 +124,8 @@ int xen_smp_intr_init(unsigned int cpu) return 0; + fail_mem: + rc = -ENOMEM; fail: xen_smp_intr_free(cpu); return rc; -- 2.43.0