Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932699AbZJAOg6 (ORCPT ); Thu, 1 Oct 2009 10:36:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932519AbZJAOg6 (ORCPT ); Thu, 1 Oct 2009 10:36:58 -0400 Received: from mail-bw0-f210.google.com ([209.85.218.210]:64940 "EHLO mail-bw0-f210.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932310AbZJAOg5 convert rfc822-to-8bit (ORCPT ); Thu, 1 Oct 2009 10:36:57 -0400 MIME-Version: 1.0 In-Reply-To: <20091001141524.GA3355@kroah.com> References: <20091001132709.GA2221@kroah.com> <20091001141524.GA3355@kroah.com> From: Kay Sievers Date: Thu, 1 Oct 2009 16:28:31 +0200 Message-ID: Subject: Re: [PATCH] drivers-core: nullify private pointer on device-release To: Greg KH Cc: Guennadi Liakhovetski , linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1324 Lines: 30 On Thu, Oct 1, 2009 at 16:15, Greg KH 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/