[PATCH] MIPS: Fix a reference leak bug in ip22_check_gio()

Haoxiang Li posted 1 patch 2 weeks, 1 day ago
arch/mips/sgi-ip22/ip22-gio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] MIPS: Fix a reference leak bug in ip22_check_gio()
Posted by Haoxiang Li 2 weeks, 1 day ago
If gio_device_register fails, gio_dev_put() is required to
drop the gio_dev device reference.

Fixes: e84de0c61905 ("MIPS: GIO bus support for SGI IP22/28")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 arch/mips/sgi-ip22/ip22-gio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index 5893ea4e382c..19b70928d6dc 100644
--- a/arch/mips/sgi-ip22/ip22-gio.c
+++ b/arch/mips/sgi-ip22/ip22-gio.c
@@ -372,7 +372,8 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq)
 		gio_dev->resource.flags = IORESOURCE_MEM;
 		gio_dev->irq = irq;
 		dev_set_name(&gio_dev->dev, "%d", slotno);
-		gio_device_register(gio_dev);
+		if (gio_device_register(gio_dev))
+			gio_dev_put(gio_dev);
 	} else
 		printk(KERN_INFO "GIO: slot %d : Empty\n", slotno);
 }
-- 
2.25.1
Re: [PATCH] MIPS: Fix a reference leak bug in ip22_check_gio()
Posted by Thomas Bogendoerfer 3 days, 23 hours ago
On Thu, Dec 04, 2025 at 06:36:18PM +0800, Haoxiang Li wrote:
> If gio_device_register fails, gio_dev_put() is required to
> drop the gio_dev device reference.
> 
> Fixes: e84de0c61905 ("MIPS: GIO bus support for SGI IP22/28")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
>  arch/mips/sgi-ip22/ip22-gio.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
> index 5893ea4e382c..19b70928d6dc 100644
> --- a/arch/mips/sgi-ip22/ip22-gio.c
> +++ b/arch/mips/sgi-ip22/ip22-gio.c
> @@ -372,7 +372,8 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq)
>  		gio_dev->resource.flags = IORESOURCE_MEM;
>  		gio_dev->irq = irq;
>  		dev_set_name(&gio_dev->dev, "%d", slotno);
> -		gio_device_register(gio_dev);
> +		if (gio_device_register(gio_dev))
> +			gio_dev_put(gio_dev);
>  	} else
>  		printk(KERN_INFO "GIO: slot %d : Empty\n", slotno);
>  }
> -- 
> 2.25.1

applied to mips-fixes

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
Re: [PATCH] MIPS: Fix a reference leak bug in ip22_check_gio()
Posted by Maciej W. Rozycki 2 weeks ago
On Thu, 4 Dec 2025, Haoxiang Li wrote:

> If gio_device_register fails, gio_dev_put() is required to
> drop the gio_dev device reference.
> 
> Fixes: e84de0c61905 ("MIPS: GIO bus support for SGI IP22/28")
> Cc: stable@vger.kernel.org

 Even if this does ever trigger in reality, it's seems like a benign issue 
that does not qualify for the -stable tree.  Please read the first section 
of Documentation/process/stable-kernel-rules.rst for the acceptance rules 
and if you still think this needs to be backported, then give rationale.

  Maciej