mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: "H.J. Lu" <hjl.tools@gmail.com>, LKML <linux-kernel@vger.kernel.org>
Cc: Jiri Kosina <jkosina@suse.com>,
	linux-input@vger.kernel.org, Sebastian Reichel <sre@kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: Re: Bad change in commit 297d716f6260cc9421d971b124ca196b957ee458?
Date: Tue, 28 Jul 2015 08:46:24 +0900	[thread overview]
Message-ID: <55B6C2D0.1050101@samsung.com> (raw)
In-Reply-To: <CAMe9rOrFxj3o6TgUAvthQLwR58-JPKO7top8w81FADjKTd5t3A@mail.gmail.com>

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

      reply	other threads:[~2015-07-27 23:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 13:10 H.J. Lu
2015-07-27 23:46 ` Krzysztof Kozlowski [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=55B6C2D0.1050101@samsung.com \
    --to=k.kozlowski@samsung.com \
    --cc=hjl.tools@gmail.com \
    --cc=jkosina@suse.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®