Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2488516lqp; Sun, 24 Mar 2024 23:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/vYvNRvXyf/VwR5/8kczdKXvytPc1G44lsdBYVAah35vu3oillZuFRLBjtqRkpbNPf1hJUg8QeJELBPIaTQnxmqefvVghzKO/h4XDsQ== X-Google-Smtp-Source: AGHT+IHoI8wz7nFk6BlqC1qq/f3o5Xqrcyt3kUiAahU2/IL9zDEd5UOWuwxESitVNQG513hkquJF X-Received: by 2002:ad4:5cca:0:b0:690:c8f7:599c with SMTP id iu10-20020ad45cca000000b00690c8f7599cmr8440201qvb.8.1711347134004; Sun, 24 Mar 2024 23:12:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347133; cv=pass; d=google.com; s=arc-20160816; b=EE35uANwkb0cGBHKKSGU8/OqOM3tgrFsvzqY5IUNehR2yZInQsP1c4khuISpaPehmt klDYNQfSGW5/hObuGc2FgyVdzlquRSSY4nDmE6KDE0z09ZG0zRsveCMo4MDJ5xRAI28U tOpfHGE4/S/z52QGJFEOXfNIu9mdwHPzqJZ/1AcY9BwIBFEBS0KhE3J2wYyOIR/+GfQ4 CS/bMNg0eb+ji9GSrHFje1JpturdCj68hsQhbzbOFC5jlLD0oTMnsIrRpO+57wWeAII6 B+uWiQOGMXfQBj/3q75FmnXN2jrpeszm3MbwX8w6sTppfEj7bnQ3uFL1BGAhqZ9Pp0lK 5CEQ== 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=kIzwChRHIVRq0uiOqr1eMibWqWPYIkcGdJY1Jy6V960=; b=NxKBkm11QUProGf36bdk3C4BJssoS1xrFgqbalDSPjP8X6C+F4OeVFw8ytToF4vyGn ZGcHs/5ZVr/o1FBBkGI3onFopvN9HrRSouO6hlmBlsL5WD7vPAojSjaC6Jx5z3A+zas1 i2rUuR2G+vX6ej4o1NloxYjN3NkiITui7S+vDrMohg15n4khHB94BYJD3p8gNcfTYO+9 8LPYCEuiEYKPF1tLUVWWAazki1Ps+LnU2M1yfatEh5UchNzI1TFAKCyml3hkOby807Z5 EQo1vhLZpsA8Datqj3AvW4tI5XKPPeIjFxaOcmYvr0u6uIERBZpyQ6rdtFht84Wk+6Fg cCNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X6O2erPl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gg3-20020a056214252300b0068efe8cf6dasi7234479qvb.12.2024.03.24.23.12.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:12:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X6O2erPl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114486-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B68EA1C2B39C for ; Mon, 25 Mar 2024 06:12:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63D5417EB6E; Sun, 24 Mar 2024 23:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X6O2erPl" 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 D692E1448D3; Sun, 24 Mar 2024 23:12:32 +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=1711321953; cv=none; b=LoLyxyAc6nwlwyjEVJ7H+KAyMLF4wDSa/H7uwu/ojFWvHemxR+BElStcfPWToP5RvWC+/IWQhm9n0GKtebvWWlIbCObYWY0/mU/qIElXXpmdtRWE+CZdrKKnn1oJ+9RgGGJrBj8TwaFmWfNZ45VQJqTH3YHEFF0+Sbw8TTTTRmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321953; c=relaxed/simple; bh=8b7DfpvkFhJ07ZMBds5WMnK3M2mYX6QhEVWSf43j/K4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aCduwzEQglxDsmtWlQmMLXa1biKLFGTWRCMKFcUOaVlIUlF31mZ79P8NpigrlU+SytT+iVBVX8s20WSAzR4WXHuGhABS08zMaL2e799KiU3Wf+0KZhOKr97TKexK8EZlinPGHbsiCGYe/RZ2RYaqKlbbua19mVj+7codOWyeRn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X6O2erPl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D916EC43390; Sun, 24 Mar 2024 23:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321952; bh=8b7DfpvkFhJ07ZMBds5WMnK3M2mYX6QhEVWSf43j/K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X6O2erPlWpIYFL7kqtFZKioSEAcflmMleC8mTFWjWkyidKDE1kwYc+LfWpHwgOs0R uBDbdzu77J/NPDFN/6tmwwDf/1hUZubWtR4GXtXisHkXcSl2EUGLcT9K0ra24TdHlO yGCRoqfauyWNBPjJWIT7sc7A+dXsp+6zNXeEaeMskEo8kf1OH4MIOP1q7SmyJHNoR6 rrHA1YwiU48DAC67Acxgvy/M9gjh+fl0LdDtncNAQ6TdwXrx+BfYKOmbkJEaGJUy24 /aHr6Qyorfy+cUd6FAEXKTmOE4VVddibFJaL5Za4m9uTp2MzZ1KQtOGng5mfhrUPEy V3q3+k/Yk7kjg== 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 Subject: [PATCH 6.1 024/451] x86/xen: Add some null pointer checking to smp.c Date: Sun, 24 Mar 2024 19:05:00 -0400 Message-ID: <20240324231207.1351418-25-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 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