[PATCH 6.18 162/175] gpio: loongson-64bit: Fix incorrect NULL check after devm_kcalloc()

Greg Kroah-Hartman
2026-02-09T14:34:54Z

From: Chen Ni <nichen@iscas.ac.cn>

[ Upstream commit e34f77b09080c86c929153e2a72da26b4f8947ff ]

Fix incorrect NULL check in loongson_gpio_init_irqchip().
The function checks chip->parent instead of chip->irq.parents.

Fixes: 03c146cb6cd1 ("gpio: loongson-64bit: Add support for Loongson-2K0300 SoC")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Link: https://patch.msgid.link/20260205072649.3271158-1-nichen@iscas.ac.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpio-loongson-64bit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-loongson-64bit.c b/drivers/gpio/gpio-loongson-64bit.c
index 82d4c3aa4d2fc..d5573fb0616ce 100644
--- a/drivers/gpio/gpio-loongson-64bit.c
+++ b/drivers/gpio/gpio-loongson-64bit.c
@@ -263,7 +263,7 @@ static int loongson_gpio_init_irqchip(struct platform_device *pdev,
chip->irq.num_parents = data->intr_num;
chip->irq.parents = devm_kcalloc(&pdev->dev, data->intr_num,
sizeof(*chip->irq.parents), GFP_KERNEL);
- if (!chip->parent)
+ if (!chip->irq.parents)
return -ENOMEM;

for (i = 0; i < data->intr_num; i++) {
--
2.51.0