public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kunwu Chan <chentao@kylinos.cn>,
	Muhammad Usama Anjum <usama.anjum@collabora.com>,
	Will Deacon <will@kernel.org>, Sasha Levin <sashal@kernel.org>,
	catalin.marinas@arm.com, shuah@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kselftest@vger.kernel.org
Subject: [PATCH AUTOSEL 6.9 21/35] kselftest: arm64: Add a null pointer check
Date: Mon, 27 May 2024 10:11:26 -0400	[thread overview]
Message-ID: <20240527141214.3844331-21-sashal@kernel.org> (raw)
In-Reply-To: <20240527141214.3844331-1-sashal@kernel.org>

From: Kunwu Chan <chentao@kylinos.cn>

[ Upstream commit 80164282b3620a3cb73de6ffda5592743e448d0e ]

There is a 'malloc' call, which can be unsuccessful.
This patch will add the malloc failure checking
to avoid possible null dereference and give more information
about test fail reasons.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20240423082102.2018886-1-chentao@kylinos.cn
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c
index 5701163460ef7..955f87c1170d7 100644
--- a/tools/testing/selftests/arm64/tags/tags_test.c
+++ b/tools/testing/selftests/arm64/tags/tags_test.c
@@ -6,6 +6,7 @@
 #include <stdint.h>
 #include <sys/prctl.h>
 #include <sys/utsname.h>
+#include "../../kselftest.h"
 
 #define SHIFT_TAG(tag)		((uint64_t)(tag) << 56)
 #define SET_TAG(ptr, tag)	(((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
@@ -21,6 +22,9 @@ int main(void)
 	if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
 		tbi_enabled = 1;
 	ptr = (struct utsname *)malloc(sizeof(*ptr));
+	if (!ptr)
+		ksft_exit_fail_msg("Failed to allocate utsname buffer\n");
+
 	if (tbi_enabled)
 		tag = 0x42;
 	ptr = (struct utsname *)SET_TAG(ptr, tag);
-- 
2.43.0


  parent reply	other threads:[~2024-05-27 14:12 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 14:11 [PATCH AUTOSEL 6.9 01/35] ssb: Fix potential NULL pointer dereference in ssb_device_uevent() Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 02/35] selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 03/35] selftests/bpf: Fix flaky test btf_map_in_map/lookup_update Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 04/35] bpf: Avoid kfree_rcu() under lock in bpf_lpm_trie Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 05/35] devlink: use kvzalloc() to allocate devlink instance resources Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 06/35] batman-adv: bypass empty buckets in batadv_purge_orig_ref() Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 07/35] wifi: rtw89: 8852c: add quirk to set PCI BER for certain platforms Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 08/35] wifi: ath9k: work around memset overflow warning Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 09/35] af_packet: avoid a false positive warning in packet_setsockopt() Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 10/35] clocksource: Make watchdog and suspend-timing multiplication overflow safe Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 11/35] ACPI: x86: Add PNP_UART1_SKIP quirk for Lenovo Blade2 tablets Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 12/35] net: sfp: add quirk for another multigig RollBall transceiver Sasha Levin
2024-05-27 14:54   ` Marek Behún
2024-06-19 14:28     ` Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 13/35] drop_monitor: replace spin_lock by raw_spin_lock Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 14/35] ACPI: resource: Do IRQ override on GMxBGxx (XMG APEX 17 M23) Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 15/35] wifi: ath12k: fix kernel crash during resume Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 16/35] scsi: qedi: Fix crash while reading debugfs attribute Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 17/35] net: sfp: enhance quirk for Fibrestore 2.5G copper SFP module Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 18/35] net: sfp: add quirk for ATS SFP-GE-T 1000Base-TX module Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 19/35] net/sched: fix false lockdep warning on qdisc root lock Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 20/35] arm64/sysreg: Update PIE permission encodings Sasha Levin
2024-05-27 14:11 ` Sasha Levin [this message]
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 22/35] net: dsa: realtek: keep default LED state in rtl8366rb Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 23/35] net: dsa: realtek: do not assert reset on remove Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 24/35] ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MV Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 25/35] netpoll: Fix race condition in netpoll_owner_active Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 26/35] wifi: ath12k: fix the problem that down grade phy mode operation Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 27/35] wifi: mt76: mt7921s: fix potential hung tasks during chip recovery Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 28/35] HID: Add quirk for Logitech Casa touchpad Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 29/35] HID: asus: fix more n-key report descriptors if n-key quirked Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 30/35] ACPI: video: Add backlight=native quirk for Lenovo Slim 7 16ARH7 Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 31/35] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Sasha Levin
2024-05-27 14:50   ` Benjamin Tissoires
2024-06-19 14:29     ` Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 32/35] bpf: avoid uninitialized warnings in verifier_global_subprogs.c Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 33/35] selftests: net: fix timestamp not arriving in cmsg_time.sh Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 34/35] net: ena: Add validation for completion descriptors consistency Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 35/35] Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl Sasha Levin

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=20240527141214.3844331-21-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=chentao@kylinos.cn \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=usama.anjum@collabora.com \
    --cc=will@kernel.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