public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Andrew Lunn <andrew@lunn.ch>, David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Russell King <rmk+kernel@arm.linux.org.uk>
Subject: Re: [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device
Date: Tue, 25 Sep 2018 11:50:44 +0300	[thread overview]
Message-ID: <99b786b5-8e27-a5a5-6130-e03028e6e82c@cogentembedded.com> (raw)
In-Reply-To: <1537828692-22861-1-git-send-email-andrew@lunn.ch>

Hello!

On 9/25/2018 1:38 AM, Andrew Lunn wrote:

> A HWMON device is only registered is the SFP module supports the

    s/is/if/?

> diagnostic page and is complient to SFF8472. Don't unconditionally

    Compliant?

> unregister the hwmon device when the SFP module is remove, otherwise
> we access data structures which don't exist.
> 
> Reported-by: Florian Fainelli <f.fainelli@gmail.com>
> Fixes: 1323061a018a ("net: phy: sfp: Add HWMON support for module sensors")
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>   drivers/net/phy/sfp.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 52fffb98fde9..23705ffae6bb 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -1098,8 +1098,11 @@ static int sfp_hwmon_insert(struct sfp *sfp)
>   
>   static void sfp_hwmon_remove(struct sfp *sfp)
>   {
> -	hwmon_device_unregister(sfp->hwmon_dev);
> -	kfree(sfp->hwmon_name);
> +	if (!PTR_ERR_OR_NULL(sfp->hwmon_dev)) {

    Already noticed. :-)

> +		hwmon_device_unregister(sfp->hwmon_dev);
> +		sfp->hwmon_dev = NULL;
> +		kfree(sfp->hwmon_name);
> +	}
>   }
>   #else
>   static int sfp_hwmon_insert(struct sfp *sfp)

MBR, Sergei

      parent reply	other threads:[~2018-09-25 14:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 22:38 [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device Andrew Lunn
2018-09-24 22:43 ` Florian Fainelli
2018-09-24 23:46   ` Andrew Lunn
2018-09-24 23:50     ` Florian Fainelli
2018-09-25  8:50 ` Sergei Shtylyov [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=99b786b5-8e27-a5a5-6130-e03028e6e82c@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    /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