From nobody Mon Sep 15 10:10:33 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 602F8C54EBD for ; Fri, 13 Jan 2023 09:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240835AbjAMJeV (ORCPT ); Fri, 13 Jan 2023 04:34:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241274AbjAMJb6 (ORCPT ); Fri, 13 Jan 2023 04:31:58 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C87665AEE for ; Fri, 13 Jan 2023 01:27:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673602044; x=1705138044; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C9eEbKq5usd6ckHzGy5EN+JxgZQpOybLQsyYvmgo4Hg=; b=gyZSANpiOtOXk23IyjUnV455ZzTIC6pixeJbeROaiKKn60e47LitZZ5C LDa7M38ObG1FasYiFZSIGuguZZAn5C54R8K9afQ1G6q2iMsRa1oEapDN1 wEzpESZcrtexSpF2u20F7qC93aP18uhUgDpjxG74pcFDCHxpb/4bdBeiX Kzk4QVm2n4SVmITNInkxxve3Qa1Qdw9tt9UIg5KS7AifZ+wr55xppTA8v y5WOYVy9h50/N+A2QdBmdJIRXoknSexl1Q1hYgj+ool8Dhja4z/jIFxC2 WSVjn1JhFKG3gCBdv9D/02LoDrJEbyo/fhRQgqX/gwPAg/ZCtQC0Wqlzs Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="351189439" X-IronPort-AV: E=Sophos;i="5.97,213,1669104000"; d="scan'208";a="351189439" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2023 01:27:23 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="608116093" X-IronPort-AV: E=Sophos;i="5.97,213,1669104000"; d="scan'208";a="608116093" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2023 01:27:22 -0800 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 2/5] soundwire: stream: use consistent pattern for freeing buffers Date: Fri, 13 Jan 2023 17:35:29 +0800 Message-Id: <20230113093532.3872113-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230113093532.3872113-1-yung-chuan.liao@linux.intel.com> References: <20230113093532.3872113-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 e0eae0b98267..f27bd37b154d 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_r= t_count) } =20 if (!multi_link) { - kfree(wr_msg); kfree(wbuf); + kfree(wr_msg); bus->defer_msg.msg =3D NULL; bus->params.curr_bank =3D !bus->params.curr_bank; bus->params.next_bank =3D !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 =3D NULL; } =20 return 0; @@ -867,6 +868,7 @@ static int do_bank_switch(struct sdw_stream_runtime *st= ream) if (bus->defer_msg.msg) { kfree(bus->defer_msg.msg->buf); kfree(bus->defer_msg.msg); + bus->defer_msg.msg =3D NULL; } } =20 --=20 2.25.1