Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp607835rwb; Wed, 18 Jan 2023 23:43:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXv/aQBdakWQWf508h/zoy7wZ4itI+lXra2POgIb13b5qF++kmda1GkSIgewbnyReN9/TeS8 X-Received: by 2002:a05:6a20:c183:b0:b6:b961:6725 with SMTP id bg3-20020a056a20c18300b000b6b9616725mr10830820pzb.41.1674114210036; Wed, 18 Jan 2023 23:43:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674114210; cv=none; d=google.com; s=arc-20160816; b=QhXuIhWyh4DoG+LpoxwqoZ53StVCWTG/dSABEet57Ofu2tDvCj2bQme2gzaDB7YVih 4c252Lu8nlSkD2ockeU3DfF+vamHOUp5dwYS5HxqygQ0xdGKKDkyNO8BSfTeI3HKXK1C 9dynhiP+f4FUaG8ft9XgmG80paZnUZ2SyKxVdJnovuIS0LsyNq+IQK6i+r+uqUBy364p BCfm8SGF1Ggf584RmicxiRpCRCJmiZBMuhAsZnwckWRd2NgMmDughjJm7vn2rCXGZ+aJ gWZ4AwJ56YX4tb6d9NevOb2YFIhnutBMunZiC6kbAgEtTyaaaLT55zYU3IOS63cFE6/m 1OKg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ff69JB+uq3Z13v2HdY2EWtoJ0E3ZvONisAvIYp+k1EE=; b=Fh5QCQsv/PBqX9mxtA+sTx4UQqpdGqDSg4lCvs8pbLYpeqJMWwAg1TCU0qCYoAX2C4 0fZY66IFuS61A+7vSNvcaerdUvZCl/XobwIyEF+wwraniEu6Z8Vsoe1QWAuyZaRYzOP0 2FyzKBrqMgRtYNS/oQhj28CPnzEmKtZGExWO46E3w13Q1i0KAzq30T0jlo5BPIQXCFQt 5LfnG8C5FmT5rY43sPBH+ytOM96qmQyQdZJOv6lc7sRGuz8yDTvU6BmGbcNxVR+VbPb2 Hg6CQJ+eukEula8SA/Uc+NJCGwmwWOHvYyHP+UFw6oQe+lFE6R/sSBPdsdpAMMRGPEPM r0gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CLpMwzCX; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm18-20020a656e92000000b004c1e81945d0si19879537pgb.557.2023.01.18.23.43.24; Wed, 18 Jan 2023 23:43:30 -0800 (PST) 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=@intel.com header.s=Intel header.b=CLpMwzCX; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbjASHYC (ORCPT + 43 others); Thu, 19 Jan 2023 02:24:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbjASHX5 (ORCPT ); Thu, 19 Jan 2023 02:23:57 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58AC8604A6 for ; Wed, 18 Jan 2023 23:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674113026; x=1705649026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FoI5xBiRDitd9OHdi7JRneCz/iRwjpZBUD404jd4Zsg=; b=CLpMwzCXkqVzQc6+7AeR5ZNzgrMEbqPdP0JoYnd8xVjP3c6CdZ/hy9f0 CCPhUjJVVZtgm4sIxbUN3MyNFkRtd7DtaErVkkjl1yopRH7yI6Bkb0IgK A2IikTkPPL68Nyncn+oNCNSCBS/r2s/DLS1egX9qdDUq15rMFVhMYS3B1 qVRQzwP35glIlJp6a2KIfT8e2joe5vE0jYqUhQUjrvfgVhjLAsn5kNXyY xbyKS7QfCk15g7lRGhHmVGYk4NzbbJJKZeJrz3xp8z9aLI8HN1zBH6PcO UZUZO7Qy0LEySANDyzRqVoKTkm4efDGRVA4T6ZyNEkWQPK8zuouKejOBu Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="322902664" X-IronPort-AV: E=Sophos;i="5.97,228,1669104000"; d="scan'208";a="322902664" 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 Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 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; } } -- 2.25.1