From patchwork Thu Sep 18 18:38:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 4933271 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BF98EBEEA5 for ; Thu, 18 Sep 2014 18:38:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D38DD20173 for ; Thu, 18 Sep 2014 18:38:32 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A320D20127 for ; Thu, 18 Sep 2014 18:38:31 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 440ED2655A4; Thu, 18 Sep 2014 20:38:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 291EF2654C5; Thu, 18 Sep 2014 20:38:25 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 87B68265560; Thu, 18 Sep 2014 20:38:24 +0200 (CEST) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by alsa0.perex.cz (Postfix) with ESMTP id 94F0E2651D1 for ; Thu, 18 Sep 2014 20:38:17 +0200 (CEST) Received: by mail-wg0-f45.google.com with SMTP id z12so1324940wgg.28 for ; Thu, 18 Sep 2014 11:38:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UJFgpHtpeHZjGobTIwKFUDEdbJmO+6QtrPaMgKPyMok=; b=UTce4uVKIYx/+Z0yPB1GrdjyXGnwqMYbbBK9PheaabOukjkMsOhvKZS5BqB4elaFvu zwtdXhNAnymzHVUUSUccvVmtAjWTK+kWqChXymnoRdjio5ZAO/oHYLDumr0hAAx8GDuW 5vh4/W1qe3+bkB7ftAzaeact3/tLabF4JsZu0piwFID5A+GeqaYju3hVp9WJ+ob4jc3W mKinvghWrYZWGSjzaiEmFFryGwwrL4vVnNg4fI32ysykJ1ILHNWfmL0GuswxYr45DFow 43746Wj1DI76LB1OA5qTM5KksJ8ZaXgolmq2JSILH4mw1SqNp9EL/6Nzzzkv7/b+tzWn 7grQ== X-Gm-Message-State: ALoCoQmjWjildkAmdB29LrLsmHf5zcHDxHUFq66VTpFMyJck8Of37FtkSLG8opB7xvOncUGQWypm X-Received: by 10.194.174.39 with SMTP id bp7mr4930181wjc.131.1411065497207; Thu, 18 Sep 2014 11:38:17 -0700 (PDT) Received: from localhost.localdomain ([91.252.11.131]) by mx.google.com with ESMTPSA id wp7sm7861816wjc.12.2014.09.18.11.38.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 11:38:16 -0700 (PDT) From: Michael Trimarchi To: nicoleotsuka@gmail.com Date: Thu, 18 Sep 2014 20:38:09 +0200 Message-Id: <1411065489-21496-1-git-send-email-michael@amarulasolutions.com> X-Mailer: git-send-email 1.8.1.2 Cc: broonie@kernel.org, Li.Xiubo@freescale.com, michael@amarulasolutions.com, timur@tabi.org, alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ASoC: fsl_ssi: fix kernel panic in probe function X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP code can raise a panic when the ssi_private->pdev is null [...] /* * If codec-handle property is missing from SSI node, we assume * that the machine driver uses new binding which does not require * SSI driver to trigger machine driver's probe. */ if (!of_get_property(np, "codec-handle", NULL)) goto done; [...] ssi_private->pdev = platform_device_register_data(&pdev->dev, name, 0, NULL, 0); [...] done: if (ssi_private->dai_fmt) _fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt); Proposal was to not use ssi_private->pdev->dev here but adding a new parameter of *dev pointer to this _set_dai_fmt() -- passing pdev->dev in probe() and cpu_dai->dev in fsl_ssi_set_dai_fmt(). Signed-off-by: Michael Trimarchi Reported-by: Jean-Michel Hautbois Cc: Nicolin Chen Acked-by: Nicolin Chen --- sound/soc/fsl/fsl_ssi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 87eb577..de6ab06 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -748,8 +748,9 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream, return 0; } -static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private, - unsigned int fmt) +static int _fsl_ssi_set_dai_fmt(struct device *dev, + struct fsl_ssi_private *ssi_private, + unsigned int fmt) { struct regmap *regs = ssi_private->regs; u32 strcr = 0, stcr, srcr, scr, mask; @@ -758,7 +759,7 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private, ssi_private->dai_fmt = fmt; if (fsl_ssi_is_i2s_master(ssi_private) && IS_ERR(ssi_private->baudclk)) { - dev_err(&ssi_private->pdev->dev, "baudclk is missing which is necessary for master mode\n"); + dev_err(dev, "baudclk is missing which is necessary for master mode\n"); return -EINVAL; } @@ -913,7 +914,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); - return _fsl_ssi_set_dai_fmt(ssi_private, fmt); + return _fsl_ssi_set_dai_fmt(cpu_dai->dev, ssi_private, fmt); } /** @@ -1387,7 +1388,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) done: if (ssi_private->dai_fmt) - _fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt); + _fsl_ssi_set_dai_fmt(&pdev->dev, ssi_private, + ssi_private->dai_fmt); return 0;