All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
	kuba@kernel.org, f.fainelli@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] net: mdio: octeon: Fix some double free issues
Date: Thu, 13 May 2021 10:44:15 +0100	[thread overview]
Message-ID: <20210513094415.GV1336@shell.armlinux.org.uk> (raw)
In-Reply-To: <7adc1815237605a0b774efb31a2ab22df51462d3.1620890610.git.christophe.jaillet@wanadoo.fr>

On Thu, May 13, 2021 at 09:24:55AM +0200, Christophe JAILLET wrote:
> 'bus->mii_bus' has been allocated with 'devm_mdiobus_alloc_size()' in the
> probe function. So it must not be freed explicitly or there will be a
> double free.
> 
> Remove the incorrect 'mdiobus_free' in the error handling path of the
> probe function and in remove function.
> 
> Suggested-By: Andrew Lunn <andrew@lunn.ch>
> Fixes: 35d2aeac9810 ("phy: mdio-octeon: Use devm_mdiobus_alloc_size()")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>

> ---
> The 'smi_en.u64 = 0; oct_mdio_writeq()' looks odd to me. Usually the normal
> path and the error handling path don't write the same value. Here, both
> write 0.
> Having '1' somewhere would 'look' more usual. :)
> More over I think that 'smi_en.s.en = 1;' in the probe is useless.

It looks fine to me.

        smi_en.u64 = 0;
        smi_en.s.en = 1;
        oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);

smi_en is a union of a u64 and a structure containing a bitfield. s.en
corresponds on LE systems with the u64 bit 0. So the above has the
effect of writing a u64 value of '1' to the SMI_EN register, whereas:

        smi_en.u64 = 0;
        oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);

has the effect of writing a u64 value of '0' to the SMI_EN register.

This code is fine.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2021-05-13  9:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13  7:24 [PATCH] net: mdio: octeon: Fix some double free issues Christophe JAILLET
2021-05-13  9:44 ` Russell King - ARM Linux admin [this message]
2021-05-13 12:22 ` Andrew Lunn
2021-05-13 22:50 ` patchwork-bot+netdevbpf

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=20210513094415.GV1336@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 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.