From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kunwu Chan <chentao@kylinos.cn>,
kernel test robot <lkp@intel.com>,
Markus Elfring <Markus.Elfring@web.de>,
Juergen Gross <jgross@suse.com>, Sasha Levin <sashal@kernel.org>,
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.6 16/21] x86/xen: Add some null pointer checking to smp.c
Date: Thu, 29 Feb 2024 10:49:36 -0500 [thread overview]
Message-ID: <20240229154946.2850012-16-sashal@kernel.org> (raw)
In-Reply-To: <20240229154946.2850012-1-sashal@kernel.org>
From: Kunwu Chan <chentao@kylinos.cn>
[ 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 <chentao@kylinos.cn>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401161119.iof6BQsf-lkp@intel.com/
Suggested-by: Markus Elfring <Markus.Elfring@web.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20240119094948.275390-1-chentao@kylinos.cn
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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
next prev parent reply other threads:[~2024-02-29 15:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 15:49 [PATCH AUTOSEL 6.6 01/21] media: Revert "media: rkisp1: Drop IRQF_SHARED" Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 02/21] media: rkisp1: Fix IRQ handling due to shared interrupts Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 03/21] Revert "drm/msm/gpu: Push gpu lock down past runpm" Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 04/21] ASoC: cs42l43: Handle error from devm_pm_runtime_enable Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 05/21] wifi: iwlwifi: mvm: use correct address 3 in A-MSDU Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 06/21] arm64: jump_label: use constraints "Si" instead of "i" Sasha Levin
2024-02-29 15:58 ` Mark Rutland
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 07/21] perf/arm-cmn: Workaround AmpereOneX errata AC04_MESH_1 (incorrect child count) Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 08/21] btrfs: add and use helper to check if block group is used Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 09/21] selftests: openvswitch: Add validation for the recursion test Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 10/21] net: tls: factor out tls_*crypt_async_wait() Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 11/21] selftests: tls: use exact comparison in recv_partial Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 12/21] ASoC: rt5645: Make LattePanda board DMI match more precise Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 13/21] spi: intel-pci: Add support for Lunar Lake-M SPI serial flash Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 14/21] regmap: kunit: Ensure that changed bytes are actually different Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 15/21] ASoC: amd: yc: Fix non-functional mic on Lenovo 82UU Sasha Levin
2024-02-29 15:49 ` Sasha Levin [this message]
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 17/21] MIPS: Clear Cause.BD in instruction_pointer_set Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 18/21] HID: multitouch: Add required quirk for Synaptics 0xcddc device Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 19/21] ASoC: SOF: ipc4-pcm: Workaround for crashed firmware on system suspend Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 20/21] gen_compile_commands: fix invalid escape sequence warning Sasha Levin
2024-02-29 15:49 ` [PATCH AUTOSEL 6.6 21/21] arm64/sve: Lower the maximum allocation for the SVE ptrace regset Sasha Levin
2024-02-29 16:51 ` Doug Anderson
2024-02-29 17:13 ` Mark Brown
2024-02-29 17:25 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240229154946.2850012-16-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Markus.Elfring@web.de \
--cc=bp@alien8.de \
--cc=chentao@kylinos.cn \
--cc=dave.hansen@linux.intel.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mingo@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox