Skip to contentSkip to conversation

ptp: Fix possible memory leak caused by invalid cast

PATCH Applied Vinicius Costa Gomes 2 participants 2 messages Aug 7, 2021 – Aug 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ptp: Fix possible memory leak caused by invalid cast

Fixes possible leak of PTP virtual clocks.

The number of PTP virtual clocks to be unregistered is passed as 'u32', but the function that unregister the devices handles that as 'u8'.

Fixes 73f37068d540 ("ptp: support ptp physical/virtual clocks conversion")

---
I am calling this "possible" because I only saw that while taking a look at the code, i.e. I didn't reproduce it.

 drivers/ptp/ptp_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ptp/ptp_sysfs.c +1 -1
index b3d96b747292..41b92dc2f011 100644
@@ -154,7 +154,7 @@ static int unregister_vclock(struct device *dev, void *data)
 	struct ptp_clock *ptp = dev_get_drvdata(dev);
 	struct ptp_clock_info *info = ptp->info;
 	struct ptp_vclock *vclock;
-	u8 *num = data;
+	u32 *num = data;
 
 	vclock = info_to_vclock(info);
 	dev_info(dev->parent, "delete virtual clock ptp%d\n",
Signature · 1 line
2.32.0
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 10 lines · On Fri, 6 Aug 2021 18:15:46 -0700 you wrote:

Fixes possible leak of PTP virtual clocks.

The number of PTP virtual clocks to be unregistered is passed as 'u32', but the function that unregister the devices handles that as 'u8'.

Fixes 73f37068d540 ("ptp: support ptp physical/virtual clocks conversion")

[...]

Here is the summary with links:
- [net,v1] ptp: Fix possible memory leak caused by invalid cast

    https://git.kernel.org/netdev/net/c/d329e41a08f3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html