From patchwork Wed Sep 10 07:57:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiao Zhou X-Patchwork-Id: 4874991 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B55F19F32E for ; Wed, 10 Sep 2014 07:58:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC73A201C7 for ; Wed, 10 Sep 2014 07:58:16 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 957122018B for ; Wed, 10 Sep 2014 07:58:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 65661261685; Wed, 10 Sep 2014 09:58:13 +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 0C041261A60; Wed, 10 Sep 2014 09:58:04 +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 07799261B31; Wed, 10 Sep 2014 09:58:02 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by alsa0.perex.cz (Postfix) with ESMTP id C72B9261685 for ; Wed, 10 Sep 2014 09:57:55 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.14.5/8.14.5) with SMTP id s8A7vsjS030748; Wed, 10 Sep 2014 00:57:54 -0700 Received: from sc-owa01.marvell.com ([199.233.58.136]) by mx0a-0016f401.pphosted.com with ESMTP id 1p9syam2y9-4 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Wed, 10 Sep 2014 00:57:53 -0700 Received: from maili.marvell.com (10.93.76.43) by sc-owa01.marvell.com (10.93.76.21) with Microsoft SMTP Server id 8.3.327.1; Wed, 10 Sep 2014 00:57:34 -0700 Received: from localhost (unknown [10.38.36.117]) by maili.marvell.com (Postfix) with ESMTP id D8BEB3F703F; Wed, 10 Sep 2014 00:57:34 -0700 (PDT) From: Qiao Zhou To: , , , , , , Date: Wed, 10 Sep 2014 15:57:32 +0800 Message-ID: <1410335852-29957-1-git-send-email-zhouqiao@marvell.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.28, 0.0.0000 definitions=2014-09-10_01:2014-09-09, 2014-09-09, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1409100085 Subject: [alsa-devel] [PATCH] ASoC: soc-pcm: fix dpcm_path_get error handling 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP dpcm_path_get may return -ENOMEM when allocating memory for list fails. We should not keep processing path or start up dpcm dai in this case. Signed-off-by: Qiao Zhou Acked-by: Vinod Koul --- sound/soc/soc-compress.c | 7 +++++-- sound/soc/soc-pcm.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 27c06ac..b969a13 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -101,10 +101,13 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) fe->dpcm[stream].runtime = fe_substream->runtime; - if (dpcm_path_get(fe, stream, &list) <= 0) { + ret = dpcm_path_get(fe, stream, &list); + if (ret < 0) { + mutex_unlock(&fe->card->mutex); + goto fe_err; + } else if (ret == 0) dev_dbg(fe->dev, "ASoC: %s no valid %s route\n", fe->dai_link->name, stream ? "capture" : "playback"); - } /* calculate valid and active FE <-> BE dpcms */ dpcm_process_paths(fe, stream, &list, 1); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 731fdb5..d341777 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2352,10 +2352,13 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream) mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); fe->dpcm[stream].runtime = fe_substream->runtime; - if (dpcm_path_get(fe, stream, &list) <= 0) { + ret = dpcm_path_get(fe, stream, &list); + if (ret < 0) { + mutex_unlock(&fe->card->mutex); + return ret; + } else if (ret == 0) dev_dbg(fe->dev, "ASoC: %s no valid %s route\n", fe->dai_link->name, stream ? "capture" : "playback"); - } /* calculate valid and active FE <-> BE dpcms */ dpcm_process_paths(fe, stream, &list, 1);