From patchwork Thu May 20 05:07:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12269031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBBE5C433B4 for ; Thu, 20 May 2021 05:08:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BFA49611AE for ; Thu, 20 May 2021 05:08:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFA49611AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8C7BF1662; Thu, 20 May 2021 07:07:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8C7BF1662 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621487301; bh=RU7m79ksh6gLtfyPuXInIc8wqVM6uCtxrPvfPRv/A2U=; h=Date:From:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=ABGdJ7YWQHEAYkFgP4gEGTYhqryO9HL44wC9MfZSG0j5Y1Bl7EdzhxuHEKkmLmeHm BbxoYOO1JpC17QR+MnuGFVSoDpZ6VQqe3C3LbMh9oggol/9cScfmacecQDup/PanzH UxU1wmNjOemALOpLu4oal3l/0lC3NpVf+YPwe/Nc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 15AFAF8020B; Thu, 20 May 2021 07:07:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9838DF80217; Thu, 20 May 2021 07:07:28 +0200 (CEST) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 044F8F800C1 for ; Thu, 20 May 2021 07:07:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 044F8F800C1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="je4wc9UF" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14K57HAc026940; Thu, 20 May 2021 05:07:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=CticVaCzxTnWWrztDkOoQDsia6opGnbN/MHwdlyE1uM=; b=je4wc9UFiYGrf+SL7B87BtMfPD7xcbOYFOY+POdLVajtNvbBj6cBKYukhw27w02zZuF0 8q/83iPXKes3XEXXOLbTCigDXsW9lblIwOcgNMtComxeFRoSwV96+PfVVFMrBTuop/CF HN1IdoGf3mKqgKCb8lBRTlK9sw9F67ksdcbMDeez14YrsUjH4oPseIpERSMhdbbMVPkn 3U2ntxoNSE6VNQDRGEuS+IyC+M25+AGqcwmui0pN1Xb+Q6AUiUcJcqBpmQ8rXNkND+fi psLc458EVnBEjjsAui9I1yKnk5B9ktA+FdwYJFTWzOlaH8xXMVhtpps5qKCyUyaPbBQt Gg== Received: from oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 38ktd2h978-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 05:07:16 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.podrdrct (8.16.0.36/8.16.0.36) with SMTP id 14K57GoN009272; Thu, 20 May 2021 05:07:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3020.oracle.com with ESMTP id 38mecm7wyc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 05:07:15 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 14K56c9E006907; Thu, 20 May 2021 05:07:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 38mecm7wxg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 05:07:14 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 14K579ew005140; Thu, 20 May 2021 05:07:09 GMT Received: from mwanda (/10.175.161.110) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 May 2021 22:07:09 -0700 Date: Thu, 20 May 2021 08:07:02 +0300 From: Dan Carpenter To: Liam Girdwood Subject: [PATCH 1/2] ASoC: topology: Fix some error codes in soc_tplg_dapm_widget_create() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-GUID: 2-YPIjwM2SAhaSJKdrghziEeSlBjhEcf X-Proofpoint-ORIG-GUID: 2-YPIjwM2SAhaSJKdrghziEeSlBjhEcf Cc: Guennadi Liakhovetski , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Ranjani Sridharan , Takashi Iwai , Mark Brown , Jaska Uimonen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" Return -ENOMEM if these allocations fail. (The current code returns success). Fixes: d29d41e28eea ("ASoC: topology: Add support for multiple kcontrol types to a widget") Signed-off-by: Dan Carpenter --- sound/soc/soc-topology.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index e71d98d7b116..6b7a813bc264 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1481,13 +1481,17 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, template.num_kcontrols = le32_to_cpu(w->num_kcontrols); kc = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(*kc), GFP_KERNEL); - if (!kc) + if (!kc) { + ret = -ENOMEM; goto err; + } kcontrol_type = devm_kcalloc(tplg->dev, le32_to_cpu(w->num_kcontrols), sizeof(unsigned int), GFP_KERNEL); - if (!kcontrol_type) + if (!kcontrol_type) { + ret = -ENOMEM; goto err; + } for (i = 0; i < w->num_kcontrols; i++) { control_hdr = (struct snd_soc_tplg_ctl_hdr *)tplg->pos; From patchwork Thu May 20 05:07:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12269033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83003C433ED for ; Thu, 20 May 2021 05:09:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54524611BD for ; Thu, 20 May 2021 05:09:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54524611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B4158167D; Thu, 20 May 2021 07:08:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B4158167D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621487352; bh=GyYk28kAogw+QlVdFzWZ2mlt1sT51ThC67X74OSAPkw=; h=Date:From:To:Subject:In-Reply-To:Cc:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From; b=POWY0SW4QSCSq6KapMUslpNeg9dYq2f/gHcv3LuCJgiLPXy02/i+HKY+LnYB94YlV V7Q6xybOBKOaQpk+/gQjKVrEVvTMb3an6uIGAFiVCeyIRLIPGQAiUNnz27gMvWOrN9 9iu9SNGzD1k6g9sTe4zluyxmdnPWE7vWyTqMVu+s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 60751F800C8; Thu, 20 May 2021 07:07:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 198FFF80272; Thu, 20 May 2021 07:07:55 +0200 (CEST) Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1224CF80229 for ; Thu, 20 May 2021 07:07:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1224CF80229 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="eRsNjkTi" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14K57oRq027317; Thu, 20 May 2021 05:07:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=EZxC9Bb9kO8469btR/OaLge4DcP3Mr1PXtR8r3X7yqs=; b=eRsNjkTiPWYNg0WwPWsTvX4nopeXjMsid7gOpIoBoqOfSDp9n69s0VAuwmFcnG+U/sbF h9mfNaHyuaVOqzmKfHuPKafW+xXgs8LaI1EWnmM3IPfx259+H0sqbCMgNn+wPu6lWdDl mSM4zMuizZEIm8aSK9By/WpIqpVu/A57fP5BH4IHNSxSVwC0r+QGVkMrJ/X8F/ngaKje frcosuWWp9/Df0joIk66fQT0gz8VnPQbU3jEUs7l1K9IyjpFeoqT9rIu+1fhVgBiJmhI ewVX6iipN0ytd4MvGGIBomoog8WZIdDDloVSz2OkbaQQoX+KHCFC/hiuYyDReEIi9P/r AA== Received: from oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 38ktd2h97c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 05:07:50 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.podrdrct (8.16.0.36/8.16.0.36) with SMTP id 14K57n0X155436; Thu, 20 May 2021 05:07:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3030.oracle.com with ESMTP id 38meegnce0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 05:07:49 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 14K57mBG155429; Thu, 20 May 2021 05:07:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 38meegncdm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 May 2021 05:07:48 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 14K57mon013731; Thu, 20 May 2021 05:07:48 GMT Received: from mwanda (/10.175.161.110) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 20 May 2021 05:07:47 +0000 Date: Thu, 20 May 2021 08:07:40 +0300 From: Dan Carpenter To: Liam Girdwood Subject: [PATCH 2/2] ASoC: topology: Fix a small leak in soc_tplg_dapm_graph_elems_load() Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email haha only kidding X-Proofpoint-GUID: 9K4pwKNgVIrANbh4l5J_SN2G1ZuxtneO X-Proofpoint-ORIG-GUID: 9K4pwKNgVIrANbh4l5J_SN2G1ZuxtneO Cc: Guennadi Liakhovetski , Cezary Rojewski , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, Takashi Iwai , Mark Brown , Amadeusz =?utf-8?b?U8WCYXdpxYRza2k=?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" We have to kfree(routes) on this error path. Fixes: ff9226224437 ("ASoC: topology: Change allocations to resource managed") Signed-off-by: Dan Carpenter --- sound/soc/soc-topology.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 6b7a813bc264..5730fcaa7bc6 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1135,8 +1135,10 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, */ for (i = 0; i < count; i++) { routes[i] = devm_kzalloc(tplg->dev, sizeof(*routes[i]), GFP_KERNEL); - if (!routes[i]) - return -ENOMEM; + if (!routes[i]) { + ret = -ENOMEM; + goto free_routes; + } } for (i = 0; i < count; i++) { @@ -1198,6 +1200,7 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, * The memory allocated for each dapm route will be freed * when it is removed in remove_route(). */ +free_routes: kfree(routes); return ret;