From patchwork Fri Oct 28 08:18:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jon Medhurst \(Tixy\)" X-Patchwork-Id: 79857 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1051872qge; Fri, 28 Oct 2016 01:19:06 -0700 (PDT) X-Received: by 10.98.155.202 with SMTP id e71mr8954185pfk.166.1477642745960; Fri, 28 Oct 2016 01:19:05 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si10282557pal.99.2016.10.28.01.19.05; Fri, 28 Oct 2016 01:19:05 -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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758769AbcJ1ITC (ORCPT + 27 others); Fri, 28 Oct 2016 04:19:02 -0400 Received: from queue01b.mail.zen.net.uk ([212.23.3.242]:51252 "EHLO queue01b.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753117AbcJ1IS6 (ORCPT ); Fri, 28 Oct 2016 04:18:58 -0400 Received: from [212.23.1.20] (helo=smarthost03a.mail.zen.net.uk) by queue01b.mail.zen.net.uk with esmtp (Exim 4.72) (envelope-from ) id 1c02NM-0002lA-Ae for linux-kernel@vger.kernel.org; Fri, 28 Oct 2016 08:18:56 +0000 Received: from [82.69.122.217] (helo=linaro1) by smarthost03a.mail.zen.net.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1c02Mr-0004W8-8Z; Fri, 28 Oct 2016 08:18:25 +0000 Message-ID: <1477642704.3083.1.camel@linaro.org> Subject: [PATCH v2] ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name when #sound-dai-cells = <0> From: "Jon Medhurst (Tixy)" To: Mark Brown Cc: Kuninori Morimoto , Jyri Sarha , Liam Girdwood , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Date: Fri, 28 Oct 2016 09:18:24 +0100 In-Reply-To: <20161027141956.GL25322@sirena.org.uk> References: <1477568568.2908.14.camel@linaro.org> <20161027141956.GL25322@sirena.org.uk> X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 X-Originating-smarthost03a-IP: [82.69.122.217] Feedback-ID: 82.69.122.217 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a DAI specifies "#sound-dai-cells = <0>" in device-tree then hdmi_of_xlate_dai_name() will be called with zero args, which it isn't implemented to cope with. The resulting use of an uninitialised variable for the id will usually result in an error like: asoc-simple-card sound: parse error -11 asoc-simple-card: probe of sound failed with error -11 Fix this by using and id of zero if no arg is provided. Fixes: 9731f82d6016 ("ASoC: hdmi-codec: enable multi probe for same device") Signed-off-by: Jon Medhurst --- Changes since v1 - Replace ternary ?: operator with if/else sound/soc/codecs/hdmi-codec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.1.4 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index b904492..90b5948 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -364,7 +364,12 @@ static int hdmi_of_xlate_dai_name(struct snd_soc_component *component, struct of_phandle_args *args, const char **dai_name) { - int id = args->args[0]; + int id; + + if (args->args_count) + id = args->args[0]; + else + id = 0; if (id < ARRAY_SIZE(hdmi_dai_name)) { *dai_name = hdmi_dai_name[id];