Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758872AbcDAKnk (ORCPT ); Fri, 1 Apr 2016 06:43:40 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:33913 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752406AbcDAKnh (ORCPT ); Fri, 1 Apr 2016 06:43:37 -0400 Date: Fri, 1 Apr 2016 12:43:33 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Sebastian Reichel , Peter Ujfalusi , Jarkko Nikula Cc: Tony Lindgren , Lars-Peter Clausen , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Pavel Machek , Aaro Koskinen , Nishanth Menon , Ivaylo Dimitrov , merlijn@wizzup.org Subject: Race condition in TPA6130A2 (Was: Re: Nokia N900 - audio TPA6130A2 problems) Message-ID: <20160401104333.GC8413@pali> References: <201507251228.27128@pali> <201601050034.12810@pali> <20160306152339.GA428@earth> <201603121342.33099@pali> <56E68B71.2030202@ti.com> <20160316133319.GR8413@pali> <20160316144709.GA3389@earth> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160316144709.GA3389@earth> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1050 Lines: 31 On Wednesday 16 March 2016 15:47:10 Sebastian Reichel wrote: > I just had another look at the driver and I think there is a race > condition for tpa6130a2_add_controls() and tpa6130a2_stereo_enable(). > > As far as I can see both functions check for "tpa6130a2_client != > NULL". tpa6130a2_client is set before the probe function has finished, > though. Simplified probe: > > ... > tpa6130a2_client = client; > set_default_regs(); > acquire_power_gpio(); > acquire_regulator(); > tpa6130a2_power(1); // needs tpa6130a2_client > check_device(); > tpa6130a2_power(0); // needs tpa6130a2_client > ... > > If tpa6130a2_add_controls() or tpa6130a2_stereo_enable() is called > after tpa6130a2 probe has started, but before probe has completed, > tpa6130a2_client is set, but not yet initialized. The race condition > can be fixed easily by moving the tpa6130a2_client assignment directly > after the regulator acquisition. > > -- Sebastian Is this race condition really relevant? If yes, then it should be fixed. -- Pali Rohár pali.rohar@gmail.com