public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop
@ 2023-07-11  2:03 Yang Rong
  2023-07-11 16:12 ` Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yang Rong @ 2023-07-11  2:03 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Rafał Miłecki,
	open list:MEMORY TECHNOLOGY DEVICES (MTD), open list
  Cc: opensource.kernel, luhongfei, Yang Rong

Ensure child node references are properly decremented in the error path
  of this function implementation.

Fixes: 2df11f00100d ("mtd: core: try to find OF node for every MTD partition")
Signed-off-by: Yang Rong <yangrong@vivo.com>
---
v2: https://lore.kernel.org/all/20230710061412.2272-1-yangrong@vivo.com/
The modifications made copared to the previous version are as follows:
1.Optimized the expression of the Subject, making it more accurate.
2.Optimized the content of the commit message.
3.Add the tag "Fixes".

 drivers/mtd/mtdcore.c | 1 +
 1 file changed, 1 insertion(+)
 mode change 100644 => 100755 drivers/mtd/mtdcore.c

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index e00b12aa5ec9..b02cb8b1a38d
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -591,6 +591,7 @@ static void mtd_check_of_node(struct mtd_info *mtd)
 		if (plen == mtd_name_len &&
 		    !strncmp(mtd->name, pname + offset, plen)) {
 			mtd_set_of_node(mtd, mtd_dn);
+			of_node_put(mtd_dn);
 			break;
 		}
 	}
-- 
2.35.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop
  2023-07-11  2:03 [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop Yang Rong
@ 2023-07-11 16:12 ` Markus Elfring
  2023-07-11 16:30   ` Richard Weinberger
  2023-07-11 16:37 ` Rafał Miłecki
  2023-07-11 17:03 ` Markus Elfring
  2 siblings, 1 reply; 6+ messages in thread
From: Markus Elfring @ 2023-07-11 16:12 UTC (permalink / raw)
  To: Yang Rong, linux-mtd, kernel-janitors, Miquel Raynal,
	Rafał Miłecki, Richard Weinberger, Vignesh Raghavendra
  Cc: opensource.kernel, LKML, Lu Hongfei

> Ensure child node references are properly decremented in the error path
>   of this function implementation.

Will leading space characters be omitted (from my wording variant suggestion)
for the final commit message?


…
> ---
> v2: https://lore.kernel.org/all/20230710061412.2272-1-yangrong@vivo.com/
> The modifications made copared to the previous version are as follows:

How do you think about the omission of a line here
(so that a repeated typo can be avoided)?

Would the subsequent enumeration look a bit nicer if each text item
will be delimited by a space character?

Regards,
Markus

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop
  2023-07-11 16:12 ` Markus Elfring
@ 2023-07-11 16:30   ` Richard Weinberger
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Weinberger @ 2023-07-11 16:30 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yang Rong, linux-mtd, kernel-janitors, Miquel Raynal,
	Rafał Miłecki, Vignesh Raghavendra, opensource kernel,
	linux-kernel, Lu Hongfei

----- Ursprüngliche Mail -----
> Von: "Markus Elfring" <Markus.Elfring@web.de>
>> v2: https://lore.kernel.org/all/20230710061412.2272-1-yangrong@vivo.com/
>> The modifications made copared to the previous version are as follows:
> 
> How do you think about the omission of a line here
> (so that a repeated typo can be avoided)?
> 
> Would the subsequent enumeration look a bit nicer if each text item
> will be delimited by a space character?

Markus, just stop it.

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop
  2023-07-11  2:03 [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop Yang Rong
  2023-07-11 16:12 ` Markus Elfring
@ 2023-07-11 16:37 ` Rafał Miłecki
  2023-07-12 12:18   ` Miquel Raynal
  2023-07-11 17:03 ` Markus Elfring
  2 siblings, 1 reply; 6+ messages in thread
From: Rafał Miłecki @ 2023-07-11 16:37 UTC (permalink / raw)
  To: Yang Rong
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd,
	linux-kernel, opensource.kernel, luhongfei

On 2023-07-11 04:03, Yang Rong wrote:
> Ensure child node references are properly decremented in the error path
>   of this function implementation.

Nitpicking: it's actually a /success/ code path that misses
of_node_put().


> Fixes: 2df11f00100d ("mtd: core: try to find OF node for every MTD 
> partition")
> Signed-off-by: Yang Rong <yangrong@vivo.com>

Acked-by: Rafał Miłecki <rafal@milecki.pl>


> ---
> v2: 
> https://lore.kernel.org/all/20230710061412.2272-1-yangrong@vivo.com/
> The modifications made copared to the previous version are as follows:
> 1.Optimized the expression of the Subject, making it more accurate.
> 2.Optimized the content of the commit message.
> 3.Add the tag "Fixes".
> 
>  drivers/mtd/mtdcore.c | 1 +
>  1 file changed, 1 insertion(+)
>  mode change 100644 => 100755 drivers/mtd/mtdcore.c
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index e00b12aa5ec9..b02cb8b1a38d
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -591,6 +591,7 @@ static void mtd_check_of_node(struct mtd_info *mtd)
>  		if (plen == mtd_name_len &&
>  		    !strncmp(mtd->name, pname + offset, plen)) {
>  			mtd_set_of_node(mtd, mtd_dn);
> +			of_node_put(mtd_dn);
>  			break;
>  		}
>  	}

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop
  2023-07-11  2:03 [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop Yang Rong
  2023-07-11 16:12 ` Markus Elfring
  2023-07-11 16:37 ` Rafał Miłecki
@ 2023-07-11 17:03 ` Markus Elfring
  2 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2023-07-11 17:03 UTC (permalink / raw)
  To: Yang Rong, linux-mtd, kernel-janitors, Miquel Raynal,
	Rafał Miłecki, Richard Weinberger, Vignesh Raghavendra
  Cc: opensource.kernel, LKML, Lu Hongfei

>  1 file changed, 1 insertion(+)
>  mode change 100644 => 100755 drivers/mtd/mtdcore.c

I find this information suspicious.
Is such a modification really required?

Regards,
Markus

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop
  2023-07-11 16:37 ` Rafał Miłecki
@ 2023-07-12 12:18   ` Miquel Raynal
  0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2023-07-12 12:18 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Yang Rong, Richard Weinberger, Vignesh Raghavendra, linux-mtd,
	linux-kernel, opensource.kernel, luhongfei

Hi Rafał,

rafal@milecki.pl wrote on Tue, 11 Jul 2023 18:37:42 +0200:

> On 2023-07-11 04:03, Yang Rong wrote:
> > Ensure child node references are properly decremented in the error path
> >   of this function implementation.  
> 
> Nitpicking: it's actually a /success/ code path that misses
> of_node_put().

Please also add:

Cc: stable...

> 
> 
> > Fixes: 2df11f00100d ("mtd: core: try to find OF node for every MTD > partition")
> > Signed-off-by: Yang Rong <yangrong@vivo.com>  
> 
> Acked-by: Rafał Miłecki <rafal@milecki.pl>
> 
> 
> > ---
> > v2: > https://lore.kernel.org/all/20230710061412.2272-1-yangrong@vivo.com/
> > The modifications made copared to the previous version are as follows:
> > 1.Optimized the expression of the Subject, making it more accurate.
> > 2.Optimized the content of the commit message.
> > 3.Add the tag "Fixes".
> > 
> >  drivers/mtd/mtdcore.c | 1 +
> >  1 file changed, 1 insertion(+)
> >  mode change 100644 => 100755 drivers/mtd/mtdcore.c
> > 
> > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> > index e00b12aa5ec9..b02cb8b1a38d
> > --- a/drivers/mtd/mtdcore.c
> > +++ b/drivers/mtd/mtdcore.c
> > @@ -591,6 +591,7 @@ static void mtd_check_of_node(struct mtd_info *mtd)
> >  		if (plen == mtd_name_len &&
> >  		    !strncmp(mtd->name, pname + offset, plen)) {
> >  			mtd_set_of_node(mtd, mtd_dn);
> > +			of_node_put(mtd_dn);
> >  			break;
> >  		}
> >  	}  


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-12 12:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-11  2:03 [PATCH v3] mtd: core: Fix resource leak in a for_each_child_of_node() loop Yang Rong
2023-07-11 16:12 ` Markus Elfring
2023-07-11 16:30   ` Richard Weinberger
2023-07-11 16:37 ` Rafał Miłecki
2023-07-12 12:18   ` Miquel Raynal
2023-07-11 17:03 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox