From patchwork Thu Jan 19 07:32:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 644131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B5DEBC38142 for ; Thu, 19 Jan 2023 07:25:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B6E075737; Thu, 19 Jan 2023 08:24:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B6E075737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1674113103; bh=FoI5xBiRDitd9OHdi7JRneCz/iRwjpZBUD404jd4Zsg=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Wu01W9MCP1S/jXV7yU3sWBgGj3rhGX0vmfTegaz/FbDXVShiehfF2JGlgogi0QlSz Pxm143MyC5wXGMh26f9+78Q4RaggHYGYQeOwGAuWEuv7Av0c3ZInxHwqemRN7mHGkY SCChK3GHkg7WgQPKtm9qOM746VMir6H5jDbX9LaE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 927BAF804E6; Thu, 19 Jan 2023 08:23:50 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 519A4F804FE; Thu, 19 Jan 2023 08:23:49 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 2374DF804DE for ; Thu, 19 Jan 2023 08:23:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2374DF804DE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ESzZsMZh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674113027; x=1705649027; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FoI5xBiRDitd9OHdi7JRneCz/iRwjpZBUD404jd4Zsg=; b=ESzZsMZhZ5x9GtZExrruTBThgDgGfz9B0G/5IpeI3gblEf1R2OaFylG4 6Yt3TpsmpdLFNxYML5QnYcMNRcfkhGzRGGFLfpPnWarzog7Sn9eL1wjEP H3otQZRUYdL6PlgMmztv82UMQDr51dGAe7eoNf3cMIgnkQ5rPj7j7jhAf /IbMF/cdLr/XLDo5lqAYwyqbFfVxkMuAn6pVSja0zhrwH5Ht0WJvO/oX4 81LrnraY7uCSsfS8Sa/tEWc173fNkp31aLYd6YDhlPovKuMJn+TAZn920 hx19BFr6j4bbeWjBP9BRXG4Hv1W6x1bqwUJntPd7k0G2jklUx39mnJvD7 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="322902665" X-IronPort-AV: E=Sophos;i="5.97,228,1669104000"; d="scan'208";a="322902665" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 23:23:45 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="662028008" X-IronPort-AV: E=Sophos;i="5.97,228,1669104000"; d="scan'208";a="662028008" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 23:23:38 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Subject: [PATCH v2 1/4] soundwire: stream: use consistent pattern for freeing buffers Date: Thu, 19 Jan 2023 15:32:08 +0800 Message-Id: <20230119073211.85979-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119073211.85979-1-yung-chuan.liao@linux.intel.com> References: <20230119073211.85979-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: pierre-louis.bossart@linux.intel.com, vinod.koul@linaro.org, bard.liao@intel.com, linux-kernel@vger.kernel.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart The code should free the message buffer used for data, the message structure used for control and assign the latter to NULL. The last part is missing for multi-link cases, and the order is inconsistent for single-link cases. Link: https://github.com/thesofproject/linux/issues/4056 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Bard Liao --- drivers/soundwire/stream.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index df3b36670df4..9c13dbd2b26e 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -723,8 +723,8 @@ static int sdw_bank_switch(struct sdw_bus *bus, int m_rt_count) } if (!multi_link) { - kfree(wr_msg); kfree(wbuf); + kfree(wr_msg); bus->defer_msg.msg = NULL; bus->params.curr_bank = !bus->params.curr_bank; bus->params.next_bank = !bus->params.next_bank; @@ -769,6 +769,7 @@ static int sdw_ml_sync_bank_switch(struct sdw_bus *bus) if (bus->defer_msg.msg) { kfree(bus->defer_msg.msg->buf); kfree(bus->defer_msg.msg); + bus->defer_msg.msg = NULL; } return 0; @@ -867,6 +868,7 @@ static int do_bank_switch(struct sdw_stream_runtime *stream) if (bus->defer_msg.msg) { kfree(bus->defer_msg.msg->buf); kfree(bus->defer_msg.msg); + bus->defer_msg.msg = NULL; } }