* [2.6 patch] net/phy/fixed.c: fix a use-after-free
@ 2008-02-02 21:15 Adrian Bunk
2008-02-03 14:21 ` Anton Vorontsov
0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2008-02-02 21:15 UTC (permalink / raw)
To: Anton Vorontsov, Vitaly Bordug, Jeff Garzik; +Cc: netdev
This patch fixes a use-after-free introduced by
commit a79d8e93d300adb84cccc38ac396cfb118c238ad and spotted by the
Coverity checker.
Signed-off-by: Adrian Bunk <bunk@kernel.org>
---
20c51455b2faed63c3026fd4d7139e5a6a917d31
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 73b6d39..ca9b040 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -236,12 +236,12 @@ module_init(fixed_mdio_bus_init);
static void __exit fixed_mdio_bus_exit(void)
{
struct fixed_mdio_bus *fmb = &platform_fmb;
- struct fixed_phy *fp;
+ struct fixed_phy *fp, *tmp;
mdiobus_unregister(&fmb->mii_bus);
platform_device_unregister(pdev);
- list_for_each_entry(fp, &fmb->phys, node) {
+ list_for_each_entry_safe(fp, tmp, &fmb->phys, node) {
list_del(&fp->node);
kfree(fp);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [2.6 patch] net/phy/fixed.c: fix a use-after-free
2008-02-02 21:15 [2.6 patch] net/phy/fixed.c: fix a use-after-free Adrian Bunk
@ 2008-02-03 14:21 ` Anton Vorontsov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2008-02-03 14:21 UTC (permalink / raw)
To: Adrian Bunk; +Cc: Vitaly Bordug, Jeff Garzik, netdev
On Sat, Feb 02, 2008 at 11:15:02PM +0200, Adrian Bunk wrote:
> This patch fixes a use-after-free introduced by
> commit a79d8e93d300adb84cccc38ac396cfb118c238ad and spotted by the
> Coverity checker.
Nice catch.
We didn't encounter this bug because fixed.c is bool, so
module_exit isn't used. Thus, technically, we can remove it
completely.
But I prefer your patch, because later, we might want to create
library versions of the fixed_mdio_bus_{init,exit}. To use, for
example, with PCI ethernet card that might have MDIO-less PHY,
i.e. configuration is hardwired in the eeprom, but driver still
want to use phylib framework.
Thanks,
> Signed-off-by: Adrian Bunk <bunk@kernel.org>
>
> ---
> 20c51455b2faed63c3026fd4d7139e5a6a917d31
> diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
> index 73b6d39..ca9b040 100644
> --- a/drivers/net/phy/fixed.c
> +++ b/drivers/net/phy/fixed.c
> @@ -236,12 +236,12 @@ module_init(fixed_mdio_bus_init);
> static void __exit fixed_mdio_bus_exit(void)
> {
> struct fixed_mdio_bus *fmb = &platform_fmb;
> - struct fixed_phy *fp;
> + struct fixed_phy *fp, *tmp;
>
> mdiobus_unregister(&fmb->mii_bus);
> platform_device_unregister(pdev);
>
> - list_for_each_entry(fp, &fmb->phys, node) {
> + list_for_each_entry_safe(fp, tmp, &fmb->phys, node) {
> list_del(&fp->node);
> kfree(fp);
> }
>
>
--
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-03 14:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-02 21:15 [2.6 patch] net/phy/fixed.c: fix a use-after-free Adrian Bunk
2008-02-03 14:21 ` Anton Vorontsov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.