Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5326547rwb; Wed, 7 Sep 2022 00:36:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WWj7INh57xHKIZaPqkWxLX0bO5Qrk/PlJHd/Rab61m8H3adRJe3Ujs/h6BkaRsRbc2mYy X-Received: by 2002:a62:55c3:0:b0:536:729:71d8 with SMTP id j186-20020a6255c3000000b00536072971d8mr2734238pfb.53.1662536202337; Wed, 07 Sep 2022 00:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662536202; cv=none; d=google.com; s=arc-20160816; b=Bua5m4CWm30wf8MPB6tI4oEPLi64R6ftzIvcXsfsfJs2F0eJYQbBYWlvstmrBfiKWW u0xzwsEv7fhJWz3CCvOtnvDchXv5I6CeLbvPKq6cdfBCfF8p7Ivpq6jA1mcneud09pXn sgSDYe7tnh8Akmr7jSWifNNmpVeymsamq3MB9mB/QgOWq6rQTzsLrTCuzbmvv1ozwAL1 KpepRYlH81TjmlS4NXE3XsFFRx1FerJbCO5l1A1DYY/DSaQCbteVp5mfBKlllXILqxJv zF9eCDCmos/iPLM+YScZoVkuyBv13FqdnJznnz12XtrpYmUe+ryBqcv8XnfHzXJ0Fi6r Cf+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gpA8V5pVUBWAKuao2rXSBnqg89Sc8Qap5SeGlb1rPH0=; b=OCpaUY7kx6JUtfTJN285zzZIa2pTBmYSsL0+jNgOsgp9BLSHJ7l5+q3loHGnaYUQAQ +HspVV9S1cYzaKImcI9cd9qJgD5FzpvP6Rn8hRB5XQY77Acqqn85f3PLJCpBXVJZTecF oDb/u/wJqpMc8aX7hqLgcEQChUSiQTKtHD8AQVHL4dfkOIkG3MT8aDx0nhc7CV6UxmK3 lSyXLFG+0rG8VxL/8SCY2qVqHCJG56DCaxzKY9sLl3txbw5AYhLTzc7EjoaTaBw+OtI+ T4GQvG235cZonuLk7ESpe+5YjevqSBDSvAjLXWXP8KwAz+V6t2JmKOanddmB5LARmmmV tmSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=DAAkSiGC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a633c0a000000b0042b8b0466d3si17289063pga.375.2022.09.07.00.36.30; Wed, 07 Sep 2022 00:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=DAAkSiGC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbiIGHAy (ORCPT + 99 others); Wed, 7 Sep 2022 03:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbiIGHAq (ORCPT ); Wed, 7 Sep 2022 03:00:46 -0400 Received: from mail-m975.mail.163.com (mail-m975.mail.163.com [123.126.97.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 923AD4D4F6 for ; Wed, 7 Sep 2022 00:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=gpA8V 5pVUBWAKuao2rXSBnqg89Sc8Qap5SeGlb1rPH0=; b=DAAkSiGC+7yrIU20vZ8vp B9wBbjLsQdyzBOl2g0JLM+jjfphlgE3BmgKhHEtLQDoPf705ABH40eGkAIcb1I6m bP4NWmKIWFZjZoHt4qWSuaU4SgZUKq+UQY0yesKko9MyaiDsfESeWs8Yr0FIfien xCYalk1PblhX/tXKznZqE4= Received: from localhost.localdomain (unknown [36.112.3.164]) by smtp5 (Coremail) with SMTP id HdxpCgB3yRFKQRhj9Mwsag--.49282S4; Wed, 07 Sep 2022 14:59:30 +0800 (CST) From: Jianglei Nie To: perex@perex.cz, tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] ALSA: hda/ca0132: fix potential memory leak in dspxfr_image() Date: Wed, 7 Sep 2022 14:59:17 +0800 Message-Id: <20220907065917.55810-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HdxpCgB3yRFKQRhj9Mwsag--.49282S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF1rCFWDGFW7uw43Kw17Wrg_yoW8Jw17pa y8KrZ8GrZ7Xr1jyw4rJ34jg3WUW3ykZFyftr4Ykw1fZ3sIgFyDXas8G3sYvF4S9FWvkryU XFWkCwn8XayDtF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zilksPUUUUU= X-Originating-IP: [36.112.3.164] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiQxJ1jFc7bS461AAAsp X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dspxfr_image() allocates DSP ports for the download stream with dsp_allocate_ports_format(). When gets some error, the allocated DSP ports are not released, which will lead to a memory leak. We can fix it by releasing DSP ports with dsp_free_ports() when getting some error. Signed-off-by: Jianglei Nie --- sound/pci/hda/patch_ca0132.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 208933792787..6b8f45e14075 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -3455,6 +3455,7 @@ static int dspxfr_image(struct hda_codec *codec, &port_map_mask); if (status < 0) { codec_dbg(codec, "alloc ports fail\n"); + dsp_free_ports(codec); goto exit; } @@ -3463,6 +3464,7 @@ static int dspxfr_image(struct hda_codec *codec, WIDGET_CHIP_CTRL, stream_id, 0, &response); if (status < 0) { codec_dbg(codec, "set stream chan fail\n"); + dsp_free_ports(codec); goto exit; } @@ -3470,6 +3472,7 @@ static int dspxfr_image(struct hda_codec *codec, if (!is_valid(fls_data)) { codec_dbg(codec, "FLS check fail\n"); status = -EINVAL; + dsp_free_ports(codec); goto exit; } status = dspxfr_one_seg(codec, fls_data, reloc, -- 2.25.1