Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652Ab3GSVIE (ORCPT ); Fri, 19 Jul 2013 17:08:04 -0400 Received: from mail-lb0-f175.google.com ([209.85.217.175]:35858 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531Ab3GSVIB (ORCPT ); Fri, 19 Jul 2013 17:08:01 -0400 MIME-Version: 1.0 In-Reply-To: References: <1374191339-10124-1-git-send-email-mcgrof@do-not-panic.com> From: "Luis R. Rodriguez" Date: Fri, 19 Jul 2013 14:07:39 -0700 X-Google-Sender-Auth: gTMEhUcpwL3jiujZR6JSEJbOAdw Message-ID: Subject: Re: [PATCH] backports: backport drvdata = NULL core driver fixes To: Alan Stern Cc: "backports@vger.kernel.org" , Hans de Goede , Julia Lawall , linux-usb@vger.kernel.org, "linux-kernel@vger.kernel.org" , Jiri Slaby , Jiri Kosina , Felix Fietkau Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2959 Lines: 74 On Fri, Jul 19, 2013 at 7:17 AM, Alan Stern wrote: > On Thu, 18 Jul 2013, Luis R. Rodriguez wrote: > >> From: "Luis R. Rodriguez" >> >> The Linux kernel had tons of code which at times cleared the >> drvdata upon probe failure or release. There are however a bunch >> of drivers that didn't clear this. >> >> Commit 0998d063 implmented clearing this upon device_release_driver() >> and dealt with probe failure on driver_probe_device(). After this the >> kernel was cleaned up separately with *tons* of patches to remove all >> these driver specific settings given that the clearing is now done >> internally by the device core. >> >> Instead of ifdef'ing code back in for older code where it was properly >> in place backport this by piggy backing the new required code upon the >> calls used in place. There is a small race here upon device_release_driver() >> but we can live with that theoretical race. >> >> Due to the way we hack this backport we can't use a separate namespace >> as we have with other symbols. >> >> mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains \ >> 0998d0631001288a5974afc0b2a5f568bcdecb4d >> v3.6-rc1~99^2~14^2~17 >> >> commit 0998d0631001288a5974afc0b2a5f568bcdecb4d >> Author: Hans de Goede >> Date: Wed May 23 00:09:34 2012 +0200 >> >> device-core: Ensure drvdata = NULL when no driver is bound >> >> 1) drvdata is for a driver to store a pointer to driver specific data >> 2) If no driver is bound, there is no driver specific data associated with >> the device >> 3) Thus logically drvdata should be NULL if no driver is bound. >> >> But many drivers don't clear drvdata on device_release, or set drvdata >> early on in probe and leave it set on probe error. Both of which results >> in a dangling pointer in drvdata. >> >> This patch enforce for drvdata to be NULL after device_release or on probe >> failure. >> >> Signed-off-by: Hans de Goede >> Signed-off-by: Greg Kroah-Hartman > > This is not a very good idea. Although setting drvdata to NULL allowed > a lot of code to be removed, it also exposed a bunch of hidden bugs -- > drivers were using the drvdata value even after their remove function > returned. Eek, have we not SmPL'ify'd a proof yet to ensure code like this no longer exists? Julia? :) > Several commits have been applied to fix those bugs. I actualy found *tons* ! > Finding and backporting them and their dependencies will not be easy. May the SmPL proof be with us. > I suggest this patch not be applied. Thanks for the review Alan! Luis -- 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/