diff mbox series

usb: typec: fix OF node reference leaks in anx7411_typec_switch_probe()

Message ID 20241116080938.3798365-1-joe@pf.is.s.u-tokyo.ac.jp (mailing list archive)
State New
Headers show
Series usb: typec: fix OF node reference leaks in anx7411_typec_switch_probe() | expand

Commit Message

Joe Hattori Nov. 16, 2024, 8:09 a.m. UTC
The refcounts of the OF nodes obtained in by of_get_child_by_name()
calls in anx7411_typec_switch_probe() are not decremented, so add
fwnode_handle_put() calls to anx7411_unregister_switch() and
anx7411_unregister_mux().

Fixes: e45d7337dc0e ("usb: typec: anx7411: Use of_get_child_by_name() instead of of_find_node_by_name()")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
---
 drivers/usb/typec/anx7411.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Greg KH Nov. 16, 2024, 8:23 a.m. UTC | #1
On Sat, Nov 16, 2024 at 05:09:38PM +0900, Joe Hattori wrote:
> The refcounts of the OF nodes obtained in by of_get_child_by_name()
> calls in anx7411_typec_switch_probe() are not decremented, so add
> fwnode_handle_put() calls to anx7411_unregister_switch() and
> anx7411_unregister_mux().
> 
> Fixes: e45d7337dc0e ("usb: typec: anx7411: Use of_get_child_by_name() instead of of_find_node_by_name()")
> Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
> ---
>  drivers/usb/typec/anx7411.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
> index d1e7c487ddfb..7e61c3ac8777 100644
> --- a/drivers/usb/typec/anx7411.c
> +++ b/drivers/usb/typec/anx7411.c
> @@ -29,6 +29,8 @@
>  #include <linux/workqueue.h>
>  #include <linux/power_supply.h>
>  
> +#include "mux.h"
> +
>  #define TCPC_ADDRESS1		0x58
>  #define TCPC_ADDRESS2		0x56
>  #define TCPC_ADDRESS3		0x54
> @@ -1088,6 +1090,7 @@ static void anx7411_unregister_mux(struct anx7411_data *ctx)
>  {
>  	if (ctx->typec.typec_mux) {
>  		typec_mux_unregister(ctx->typec.typec_mux);
> +		fwnode_handle_put(ctx->typec.typec_mux->dev.fwnode);
>  		ctx->typec.typec_mux = NULL;
>  	}
>  }
> @@ -1096,6 +1099,7 @@ static void anx7411_unregister_switch(struct anx7411_data *ctx)
>  {
>  	if (ctx->typec.typec_switch) {
>  		typec_switch_unregister(ctx->typec.typec_switch);
> +		fwnode_handle_put(ctx->typec.typec_switch->dev.fwnode);
>  		ctx->typec.typec_switch = NULL;
>  	}
>  }
> -- 
> 2.34.1
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
diff mbox series

Patch

diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index d1e7c487ddfb..7e61c3ac8777 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -29,6 +29,8 @@ 
 #include <linux/workqueue.h>
 #include <linux/power_supply.h>
 
+#include "mux.h"
+
 #define TCPC_ADDRESS1		0x58
 #define TCPC_ADDRESS2		0x56
 #define TCPC_ADDRESS3		0x54
@@ -1088,6 +1090,7 @@  static void anx7411_unregister_mux(struct anx7411_data *ctx)
 {
 	if (ctx->typec.typec_mux) {
 		typec_mux_unregister(ctx->typec.typec_mux);
+		fwnode_handle_put(ctx->typec.typec_mux->dev.fwnode);
 		ctx->typec.typec_mux = NULL;
 	}
 }
@@ -1096,6 +1099,7 @@  static void anx7411_unregister_switch(struct anx7411_data *ctx)
 {
 	if (ctx->typec.typec_switch) {
 		typec_switch_unregister(ctx->typec.typec_switch);
+		fwnode_handle_put(ctx->typec.typec_switch->dev.fwnode);
 		ctx->typec.typec_switch = NULL;
 	}
 }