From: Jean Delvare Subject: Re: [PATCH] sound: Don't assume i2c device probing always succeeds Date: Wed, 30 Sep 2009 17:00:06 +0200 Message-ID: <20090930170006.76e145ca@hyperion.delvare> References: <20090930152542.3ef753ee@hyperion.delvare> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from poutre.nerim.net (poutre.nerim.net [62.4.16.124]) by alsa0.perex.cz (Postfix) with ESMTP id A6F31103810 for ; Wed, 30 Sep 2009 17:00:08 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Takashi Iwai Cc: linuxppc-dev@ozlabs.org, Johannes Berg , Tim Shepard , alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org Hi Takashi, Thanks for the swift reply. On Wed, 30 Sep 2009 16:13:49 +0200, Takashi Iwai wrote: > At Wed, 30 Sep 2009 15:25:42 +0200, > Jean Delvare wrote: > > > > If i2c device probing fails, then there is no driver to dereference > > after calling i2c_new_device(). Stop assuming that probing will always > > succeed, to avoid NULL pointer dereferences. We have an easier access > > to the driver anyway. > > > > Reported-by: Tim Shepard > > Signed-off-by: Jean Delvare > > Cc: Johannes Berg > > --- > > The code is similar to the one in therm_adt746x, for which Tim reported > > a real-world oops, so it should be fixed ASAP. > > Jean, thanks for the patch. > > I'm just wondering whether the additional NULL check of client->driver > would be enough? If yes, sound/aoa/onyx.c has it, at least, and we > can add the similar checks to the rest, too. The NULL check of client->driver, if followed by a call to i2c_unregister_device(), would indeed be enough. But unlike the onyx driver which we know we sometimes load erroneously, the other drivers should never fail. I am reluctant to add code to handle error cases which are not supposed to happen, which is why I prefer my proposed fix: it does not add code. That being said, I will be happy with any solution that fixes the problem, so if you prefer client->driver NULL checks, I can send a patch doing this. Thanks, -- Jean Delvare