mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: Greg KH <greg@kroah.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers-core: nullify private pointer on device-release
Date: Thu, 1 Oct 2009 16:28:31 +0200	[thread overview]
Message-ID: <ac3eb2510910010728v33e76f2ev751c20b3e454cf7a@mail.gmail.com> (raw)
In-Reply-To: <20091001141524.GA3355@kroah.com>

On Thu, Oct 1, 2009 at 16:15, Greg KH <greg@kroah.com> wrote:
> On Thu, Oct 01, 2009 at 03:45:56PM +0200, Guennadi Liakhovetski wrote:

>> My problem case is the soc-camera framework. There device struct is
>> embedded into the video client object, which are kept as long as the
>> driver is loaded.
>
> struct device is a dynamic structure, it is supposed to be able to be
> freed when the last reference goes away.  Static struct device usage is
> wrong.  It sounds like the video client object code is incorrect, please
> fix it.

Exactly. If you keep your "object" around for forever, you must never
embed a struct device but only a pointer to one that is managed by the
core. Embedding a struct device defers lifetime management of the
enclosing object to the driver core reference counts.

You can not have both, you have to decide to let your objects be
managed by the driver core reference, or just point to a dynamic
driver core object. All driver core objects are always dynamic,
everything else just seem to work, but are not expected to work
reliably.

Thanks,
Kay

  reply	other threads:[~2009-10-01 14:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-01  8:02 Guennadi Liakhovetski
2009-10-01 13:27 ` Greg KH
2009-10-01 13:45   ` Guennadi Liakhovetski
2009-10-01 14:15     ` Greg KH
2009-10-01 14:28       ` Kay Sievers [this message]
2009-10-05  8:11       ` Guennadi Liakhovetski
2009-10-05 16:03         ` Greg KH
2009-10-05 16:14           ` Guennadi Liakhovetski
2009-10-05 16:30             ` Greg KH

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=ac3eb2510910010728v33e76f2ev751c20b3e454cf7a@mail.gmail.com \
    --to=kay.sievers@vrfy.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=greg@kroah.com \
    --cc=linux-kernel@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 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®