All of lore.kernel.org
 help / color / mirror / Atom feed
* Bad change in commit 297d716f6260cc9421d971b124ca196b957ee458?
@ 2015-07-27 13:10 H.J. Lu
  2015-07-27 23:46 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2015-07-27 13:10 UTC (permalink / raw)
  To: Krzysztof Kozlowski, LKML

Hi,

This commit:

commit 297d716f6260cc9421d971b124ca196b957ee458
Author: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Date:   Thu Mar 12 08:44:11 2015 +0100

    power_supply: Change ownership from driver to core

    Change the ownership of power_supply structure from each driver
    implementing the class to the power supply core.

has

static void hidinput_cleanup_battery(struct hid_device *dev)
 {
-       if (!dev->battery.name)
+       if (!dev->battery)
                return;

-       power_supply_unregister(&dev->battery);
-       kfree(dev->battery.name);
-       dev->battery.name = NULL;
+       power_supply_unregister(dev->battery);
+       kfree(dev->battery->desc->name);
+       kfree(dev->battery->desc);
+       dev->battery = NULL;
 }

Is this OK to access dev->battery after calling power_supply_unregister?

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bad change in commit 297d716f6260cc9421d971b124ca196b957ee458?
  2015-07-27 13:10 Bad change in commit 297d716f6260cc9421d971b124ca196b957ee458? H.J. Lu
@ 2015-07-27 23:46 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2015-07-27 23:46 UTC (permalink / raw)
  To: H.J. Lu, LKML
  Cc: Jiri Kosina, linux-input, Sebastian Reichel,
	linux-pm@vger.kernel.org

On 27.07.2015 22:10, H.J. Lu wrote:
> Hi,
> 
> This commit:
> 
> commit 297d716f6260cc9421d971b124ca196b957ee458
> Author: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Date:   Thu Mar 12 08:44:11 2015 +0100
> 
>     power_supply: Change ownership from driver to core
> 
>     Change the ownership of power_supply structure from each driver
>     implementing the class to the power supply core.
> 
> has
> 
> static void hidinput_cleanup_battery(struct hid_device *dev)
>  {
> -       if (!dev->battery.name)
> +       if (!dev->battery)
>                 return;
> 
> -       power_supply_unregister(&dev->battery);
> -       kfree(dev->battery.name);
> -       dev->battery.name = NULL;
> +       power_supply_unregister(dev->battery);
> +       kfree(dev->battery->desc->name);
> +       kfree(dev->battery->desc);
> +       dev->battery = NULL;
>  }
> 
> Is this OK to access dev->battery after calling power_supply_unregister?

(+Cc Jiri, linux-input, linux-pm, Sebastian)

Good catch, it is not safe. The final device_unregister() will free the
structure.

We should access directly psy_desc here. I'll sent a proposal of fixing
this and check other drivers for this pattern.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-27 23:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-27 13:10 Bad change in commit 297d716f6260cc9421d971b124ca196b957ee458? H.J. Lu
2015-07-27 23:46 ` Krzysztof Kozlowski

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.