Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp675676ybh; Sat, 3 Aug 2019 07:29:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwR7+Nhzbzm//BtGdXi+yu/SrVLyIxV/pjYtKfEhsfvR1iDaQ5ARxbNEweIy/nsQvOjcQBG X-Received: by 2002:a63:2004:: with SMTP id g4mr123189343pgg.97.1564842588049; Sat, 03 Aug 2019 07:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564842588; cv=none; d=google.com; s=arc-20160816; b=HBC9DvNB1DvZuM7pQDVu3Ym/c5SHqHLJ0YxGv7ZX/EKkZPYBUpd5p/+7iifPxBCrVL 69pgzv1RVf7HjMF5YF0fLYLxYbH6marAPZ2liq9omEvX5W96wTm/OXiJJuBrJQd6sLOd k7eblfLZYoypVlrLQbHkZiUcqcL7cdhIfAcxubUznisswk691bmtjZDIRrr+XLVGaPQf bZAtdg55ZFTkpLoeCmX79ViZOpMe82VpLj9EyJF992Di0ngd5FmCbvJ+7Ir9Hc7kXwQk f9PvndRUvxZVfL1drhLF1Dgy7jqBVm+F8xuHOPRSG1RlXNINc8kYdN1Jz0g9bjLltIi+ Abzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=KkZTo1tI+4UwYglKuB7vOdyiMXqEQHmrwo4LDunFFRA=; b=I3oZ2O6LSkf2Qfqiw7d6B4Tcb77OzXnV4Z3taDnO2DM/HlORktzOxaKnsDSSPJblG8 4/TLOPKJudx/MV8ItHFP4RcQJwRviWvt3RS8xkvNcDXC38loErXpebLaTXKEiadpWXQP 3gr8OYaGRKcekFykh0F9yLZKIrp3Xm72ipFWhPsUjGKQERzJqz1cmEP4D2+A7LnwbCh2 dk5v9eFqABO3jPhhF+3QkACw3TaPoAHS4LdI7DeknODUow6B0Q8/56qDpHDnBInesaBs RlttxGab77XLD1HbMwtNrtAV6kLCPPfSGAgQk99Fb3LWSREoauA0UR/oeUtqcM+RwwKC 9vug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si36060396plk.388.2019.08.03.07.29.32; Sat, 03 Aug 2019 07:29:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395148AbfHBPQM (ORCPT + 99 others); Fri, 2 Aug 2019 11:16:12 -0400 Received: from mga18.intel.com ([134.134.136.126]:27394 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730768AbfHBPQL (ORCPT ); Fri, 2 Aug 2019 11:16:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Aug 2019 08:16:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,338,1559545200"; d="scan'208";a="175609709" Received: from vivekcha-mobl1.amr.corp.intel.com (HELO [10.251.131.115]) ([10.251.131.115]) by orsmga003.jf.intel.com with ESMTP; 02 Aug 2019 08:16:09 -0700 Subject: Re: [alsa-devel] [RFC PATCH 06/40] soundwire: intel: prevent possible dereference in hw_params To: Vinod Koul Cc: alsa-devel@alsa-project.org, tiwai@suse.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, broonie@kernel.org, srinivas.kandagatla@linaro.org, jank@cadence.com, slawomir.blauciak@intel.com, Sanyog Kale References: <20190725234032.21152-1-pierre-louis.bossart@linux.intel.com> <20190725234032.21152-7-pierre-louis.bossart@linux.intel.com> <20190802115537.GI12733@vkoul-mobl.Dlink> From: Pierre-Louis Bossart Message-ID: <6da5aeef-40bf-c9bb-fc18-4ac0b3961857@linux.intel.com> Date: Fri, 2 Aug 2019 10:16:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190802115537.GI12733@vkoul-mobl.Dlink> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/2/19 6:55 AM, Vinod Koul wrote: > On 25-07-19, 18:39, Pierre-Louis Bossart wrote: >> This should not happen in production systems but we should test for >> all callback arguments before invoking the config_stream callback. > > so you are saying callback arg is mandatory, if so please document that > assumption no, what this says is that if a config_stream is provided then it needs to have a valid argument. I am not sure what you mean by "document that assumption", comment in the code (where?) or SoundWire documentation? > >> Signed-off-by: Pierre-Louis Bossart >> --- >> drivers/soundwire/intel.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c >> index 68832e613b1e..497879dd9c0d 100644 >> --- a/drivers/soundwire/intel.c >> +++ b/drivers/soundwire/intel.c >> @@ -509,7 +509,7 @@ static int intel_config_stream(struct sdw_intel *sdw, >> struct snd_soc_dai *dai, >> struct snd_pcm_hw_params *hw_params, int link_id) >> { >> - if (sdw->res->ops && sdw->res->ops->config_stream) >> + if (sdw->res->ops && sdw->res->ops->config_stream && sdw->res->arg) >> return sdw->res->ops->config_stream(sdw->res->arg, >> substream, dai, hw_params, link_id); >> >> -- >> 2.20.1 >