From f82a9fc2acf37ff2bdd13cf4e0e3690d29b5a679 Mon Sep 17 00:00:00 2001 From: leoliu-oc Date: Thu, 1 Feb 2024 15:39:58 +0800 Subject: [PATCH] perf/x86/zhaoxin/uncore: add NULL pointer check after kzalloc zhaoxin inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I90GXO CVE: NA ----------------- Add NULL pointer check after kzalloc in uncore_pci_probe(). Signed-off-by: leoliu-oc --- arch/x86/events/zhaoxin/uncore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/events/zhaoxin/uncore.c b/arch/x86/events/zhaoxin/uncore.c index bde0693be1cd..8a11fc98d479 100644 --- a/arch/x86/events/zhaoxin/uncore.c +++ b/arch/x86/events/zhaoxin/uncore.c @@ -1591,6 +1591,8 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id loop = 1; boxes = kzalloc(loop * sizeof(struct zhaoxin_uncore_box *), GFP_KERNEL); + if (!boxes) + return -ENOMEM; for (i = 0; i < loop; i++) { type = uncore_pci_uncores[UNCORE_PCI_DEV_TYPE(id->driver_data) + j]; -- Gitee