* [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device
@ 2018-09-24 22:38 Andrew Lunn
2018-09-24 22:43 ` Florian Fainelli
2018-09-25 8:50 ` Sergei Shtylyov
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Lunn @ 2018-09-24 22:38 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Florian Fainelli, Russell King, Andrew Lunn
A HWMON device is only registered is the SFP module supports the
diagnostic page and is complient to SFF8472. Don't unconditionally
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)) {
+ hwmon_device_unregister(sfp->hwmon_dev);
+ sfp->hwmon_dev = NULL;
+ kfree(sfp->hwmon_name);
+ }
}
#else
static int sfp_hwmon_insert(struct sfp *sfp)
--
2.19.0.rc1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device
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-25 8:50 ` Sergei Shtylyov
1 sibling, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2018-09-24 22:43 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: netdev, Russell King
On 09/24/2018 03:38 PM, Andrew Lunn wrote:
> A HWMON device is only registered is the SFP module supports the
> diagnostic page and is complient to SFF8472. Don't unconditionally
> 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)) {
I believe this should be IS_ERR_OR_NULL(), there is no PTR_ERR_OR_NULL()
in the Linux tree AFAICT.
> + hwmon_device_unregister(sfp->hwmon_dev);
> + sfp->hwmon_dev = NULL;
> + kfree(sfp->hwmon_name);
> + }
> }
> #else
> static int sfp_hwmon_insert(struct sfp *sfp)
>
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device
2018-09-24 22:43 ` Florian Fainelli
@ 2018-09-24 23:46 ` Andrew Lunn
2018-09-24 23:50 ` Florian Fainelli
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-09-24 23:46 UTC (permalink / raw)
To: Florian Fainelli; +Cc: David Miller, netdev, Russell King
On Mon, Sep 24, 2018 at 03:43:33PM -0700, Florian Fainelli wrote:
> On 09/24/2018 03:38 PM, Andrew Lunn wrote:
> > A HWMON device is only registered is the SFP module supports the
> > diagnostic page and is complient to SFF8472. Don't unconditionally
> > 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)) {
>
> I believe this should be IS_ERR_OR_NULL(), there is no PTR_ERR_OR_NULL()
> in the Linux tree AFAICT.
Yep.
Please ignore this patch.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device
2018-09-24 23:46 ` Andrew Lunn
@ 2018-09-24 23:50 ` Florian Fainelli
0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-09-24 23:50 UTC (permalink / raw)
To: Andrew Lunn; +Cc: David Miller, netdev, Russell King
On 09/24/2018 04:46 PM, Andrew Lunn wrote:
> On Mon, Sep 24, 2018 at 03:43:33PM -0700, Florian Fainelli wrote:
>> On 09/24/2018 03:38 PM, Andrew Lunn wrote:
>>> A HWMON device is only registered is the SFP module supports the
>>> diagnostic page and is complient to SFF8472. Don't unconditionally
>>> 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)) {
>>
>> I believe this should be IS_ERR_OR_NULL(), there is no PTR_ERR_OR_NULL()
>> in the Linux tree AFAICT.
>
> Yep.
>
> Please ignore this patch.
After fixing this locally, this worked, feel free to add a
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
to your v2. Thanks for the fix!
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: phy: sfp: Fix unregistering of HWMON SFP device
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-25 8:50 ` Sergei Shtylyov
1 sibling, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2018-09-25 8:50 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: netdev, Florian Fainelli, Russell King
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-09-25 14:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox