public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Russell King <linux@armlinux.org.uk>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Igor Grinberg <grinberg@compulab.co.il>,
	Felipe Balbi <balbi@ti.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ARM: pxa: Fix a memory leak in pxa310_otg_exit()
Date: Wed, 3 Aug 2022 16:31:09 +0300	[thread overview]
Message-ID: <20220803133109.GD3438@kadam> (raw)
In-Reply-To: <890e3e7329b020356206262e9c3ee57378648e1c.1659506415.git.christophe.jaillet@wanadoo.fr>

On Wed, Aug 03, 2022 at 08:00:44AM +0200, Christophe JAILLET wrote:
>  arch/arm/mach-pxa/pxa3xx-ulpi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/mach-pxa/pxa3xx-ulpi.c b/arch/arm/mach-pxa/pxa3xx-ulpi.c
> index c29a7f0fa1b0..82b4e2706f86 100644
> --- a/arch/arm/mach-pxa/pxa3xx-ulpi.c
> +++ b/arch/arm/mach-pxa/pxa3xx-ulpi.c
> @@ -229,6 +229,7 @@ static int pxa310_otg_init(struct pxa3xx_u2d_platform_data *pdata)
>  
>  static void pxa310_otg_exit(void)
>  {
> +	kfree(u2d->otg->otg);
>  	kfree(u2d->otg);

It's unfortunate that we kept the "otg" name when changed u2d->otg to
a phy.  A lot of the stuff was renamed...  I don't have a cross compile
system set up either so I can't patch it but looks reasonably simple to
rename the remaining instance to phy?

diff --git a/arch/arm/mach-pxa/pxa3xx-ulpi.c b/arch/arm/mach-pxa/pxa3xx-ulpi.c
index c29a7f0fa1b0..a002fe1e96a2 100644
--- a/arch/arm/mach-pxa/pxa3xx-ulpi.c
+++ b/arch/arm/mach-pxa/pxa3xx-ulpi.c
@@ -30,7 +30,7 @@ struct pxa3xx_u2d_ulpi {
 	struct clk		*clk;
 	void __iomem		*mmio_base;
 
-	struct usb_phy		*otg;
+	struct usb_phy		*phy;
 	unsigned int		ulpi_mode;
 };
 
@@ -76,7 +76,7 @@ static int pxa310_ulpi_poll(void)
 	return -ETIMEDOUT;
 }
 
-static int pxa310_ulpi_read(struct usb_phy *otg, u32 reg)
+static int pxa310_ulpi_read(struct usb_phy *phy, u32 reg)
 {
 	int err;
 
@@ -95,7 +95,7 @@ static int pxa310_ulpi_read(struct usb_phy *otg, u32 reg)
 	return u2d_readl(U2DOTGUCR) & U2DOTGUCR_RDATA;
 }
 
-static int pxa310_ulpi_write(struct usb_phy *otg, u32 val, u32 reg)
+static int pxa310_ulpi_write(struct usb_phy *phy, u32 val, u32 reg)
 {
 	if (pxa310_ulpi_get_phymode() != SYNCH) {
 		pr_warn("%s: PHY is not in SYNCH mode!\n", __func__);
@@ -136,19 +136,19 @@ static int pxa310_start_otg_host_transcvr(struct usb_bus *host)
 
 	pxa310_otg_transceiver_rtsm();
 
-	err = usb_phy_init(u2d->otg);
+	err = usb_phy_init(u2d->phy);
 	if (err) {
 		pr_err("OTG transceiver init failed");
 		return err;
 	}
 
-	err = otg_set_vbus(u2d->otg->otg, 1);
+	err = otg_set_vbus(u2d->phy->otg, 1);
 	if (err) {
 		pr_err("OTG transceiver VBUS set failed");
 		return err;
 	}
 
-	err = otg_set_host(u2d->otg->otg, host);
+	err = otg_set_host(u2d->phy->otg, host);
 	if (err)
 		pr_err("OTG transceiver Host mode set failed");
 
@@ -186,9 +186,9 @@ static void pxa310_stop_otg_hc(void)
 {
 	pxa310_otg_transceiver_rtsm();
 
-	otg_set_host(u2d->otg->otg, NULL);
-	otg_set_vbus(u2d->otg->otg, 0);
-	usb_phy_shutdown(u2d->otg);
+	otg_set_host(u2d->phy->otg, NULL);
+	otg_set_vbus(u2d->phy->otg, 0);
+	usb_phy_shutdown(u2d->phy);
 }
 
 static void pxa310_u2d_setup_otg_hc(void)
@@ -218,18 +218,18 @@ static int pxa310_otg_init(struct pxa3xx_u2d_platform_data *pdata)
 
 	u2d->ulpi_mode = ulpi_mode;
 
-	u2d->otg = otg_ulpi_create(&pxa310_ulpi_access_ops, ulpi_mode);
-	if (!u2d->otg)
+	u2d->phy = otg_ulpi_create(&pxa310_ulpi_access_ops, ulpi_mode);
+	if (!u2d->phy)
 		return -ENOMEM;
 
-	u2d->otg->io_priv = u2d->mmio_base;
+	u2d->phy->io_priv = u2d->mmio_base;
 
 	return 0;
 }
 
 static void pxa310_otg_exit(void)
 {
-	kfree(u2d->otg);
+	kfree(u2d->phy);
 }
 #else
 static inline void pxa310_u2d_setup_otg_hc(void) {}

      reply	other threads:[~2022-08-03 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  6:00 [PATCH] ARM: pxa: Fix a memory leak in pxa310_otg_exit() Christophe JAILLET
2022-08-03 13:31 ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220803133109.GD3438@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=balbi@ti.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=daniel@zonque.org \
    --cc=grinberg@compulab.co.il \
    --cc=haojian.zhuang@gmail.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marek.vasut@gmail.com \
    --cc=robert.jarzmik@free.fr \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox