Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754006AbbKLJDN (ORCPT ); Thu, 12 Nov 2015 04:03:13 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:33662 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753903AbbKLJDJ (ORCPT ); Thu, 12 Nov 2015 04:03:09 -0500 Date: Thu, 12 Nov 2015 10:03:07 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Wolfram Sang Cc: LABBE Corentin , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] i2c: rcar: fix a possible NULL dereference Message-ID: <20151112090307.GH24008@pengutronix.de> References: <1447313109-23583-1-git-send-email-clabbe.montjoie@gmail.com> <20151112074447.GA24008@pengutronix.de> <20151112075238.GA1551@katana> <20151112080926.GC24008@pengutronix.de> <20151112084837.GA2782@katana> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20151112084837.GA2782@katana> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1730 Lines: 49 On Thu, Nov 12, 2015 at 09:48:37AM +0100, Wolfram Sang wrote: > On Thu, Nov 12, 2015 at 09:09:26AM +0100, Uwe Kleine-K?nig wrote: > > Hello Wolfram, > > > > On Thu, Nov 12, 2015 at 08:52:38AM +0100, Wolfram Sang wrote: > > > On Thu, Nov 12, 2015 at 08:44:47AM +0100, Uwe Kleine-K?nig wrote: > > > > Other than that, the NULL pointer dereference should only happen if the > > > > device was bound using the driver name. That might be worth to point out > > > > in the commit log. So maybe make (in a separate patch) the probe > > > > function fail when probed by name? > > > > > > RCar is a DT only platform. > > > > Does this imply that no checking is needed? I'm not sure. > > I don't see how this driver could get probed otherwise. That being said, > for the "better safe than sorry" approach, I'd accept your suggestion. Try adding the following to a device tree: i2c-rcar { } This creates a platform device with name=i2c-rcar which makes platform_match() yield a match for your driver. (The other alternative is a device with this name created by a platform file (even if this is not an rcar machine) doesn't trigger that problem here I think, because there is a platform_device_id with a matching name). See also http://article.gmane.org/gmane.linux.kernel/2083641 for a similar discussion. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ | -- 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/