From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58C3B3E4C7D for ; Fri, 26 Jun 2026 08:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782462580; cv=none; b=U6n4m6TUoy/XT9CEbfoLRUFtSmmh7sTCk9GIPRKaj/7G8RazcYbvlFMTfZPk4IMHFng8F1VOeugCbge5ydD6Y+CTVnjByxz+ZiX45s0fxhjFMFpRv+0oJX6njY478kWQtyQwkoIzCaq5gi3+nCRkGpO/4z3LjmKb7JdxALcYlk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782462580; c=relaxed/simple; bh=UXHJAmlXNESOzLWgFCYAkLO6a7PCdsPm/sU4cVQ489o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VA782pn+UTQi7Qqv/Kn8qlrZz1CUwa9CuztW2mnWWi9Q7rEowDsIkZkJvtF/3ep3DM4fidGW51CiPQYDhzfku7evlbHcKrakdNWnjjckpLDXNU/aSSYvfHhaDaKRCi30sLACsnZFpn0R8NsMaaDrXwpziI3l6WLwx3yAjmLh9F0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RmlLQWNO; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RmlLQWNO" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8454160043aso572299b3a.3 for ; Fri, 26 Jun 2026 01:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782462578; x=1783067378; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gnC/KTm8/lGG/pCjPtXCtDzzd1NJTdJhFKdzhH6Wel0=; b=RmlLQWNOWjEueH/qLWNPAmhRxQ5FlGZoBGZtpUhqJFMnuPwHSW51w2Ef1lr1kSjAQ9 ZMqyJcUl5Z6FntYlsJpwDRs6UwWZAA58iUSBMEtjcL0bHn7bH1bbqjRNyXo9B1IYw4mF YbmWdz0h/UvMusMv0XU5N2hSYUx2FQmB2Tzx2MXZhohEnFhUXChoVAiLTL4brFMwY+ff disPz+4Wu3Rhgn+DPcd3gYjKFmzHbym5qUe+QgHNPf48DQ7Dwdvg3ESHhm5G/dOOhdlS x5GAmI6hW4ninJwTcEMChEWK/1PfnEWYJPMTSzwE4PQ1s7OBhucPM8y6ykZnKgcTIaiW TK2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782462578; x=1783067378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gnC/KTm8/lGG/pCjPtXCtDzzd1NJTdJhFKdzhH6Wel0=; b=AVcL9SDB44ePgDxIpVhAKJvH7Ur8UOPdFI+3Yk8DOi+Zpk2lgDwUObEB/HSgnhMO/3 ofCTtKmx9FAt4mBAjplX+EKUi27cjMd0k0uBAGRNUWetLsQiGskHNJIdnV0zeoPjRNkO EXk+me9nk9PLOfiObsXvke0kuKKLTPMapMAxkxF77L4BMov877LCTlLDA3RGpB9UoSzY A4m51FPhhMd8HK7ByRAdO9bbnB0NyeX0tAMAtH4HmQrlCvCF7tLayv7/1yqVDpMwdh8d ttd6c6bJ4H/SqN+QyXJoD43q2OYGo9lKtj9LnIcNSSj+zUkE1ZorZHc1D+thSHU3C824 g1pQ== X-Forwarded-Encrypted: i=1; AFNElJ+nKaj/0iIy/GS97/0wbokuc18sxgoh1G4GVbJV4iYt1xlnZ4uTme+lCWAn8FNHWRR+KsyhPxR5MyrpBFU=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn/Yyyg9Z17lf3/X/BUxj+NFnjtTlu2kJn83zZjXEa+vGrmHRk NZQqQHY4QQCPF46O5P1xW14LHe6tWaTJ+vSg1elju64j0wUL3NaA3Ar7 X-Gm-Gg: AfdE7ckqC1SllEY5H0EbLkz8502tyeVSvu7OYL93bMLHG2x1XloLnq6EKgkpf6QVeRL mnw5rP+2B92bI23HkwMzHJT2V1SEjcpQRQEixs0HzKZ2sRO1e6R9ijZnMOoa7tUGFNsuKjqxFf+ 25zjnPmzKN5kjcbeyRGv2dk536o3YlvV2AyNEwIDy/2O+vKdWjaIFua74Tfpr0VGXr3b21c+bpC EXWFsy6tGfFz5V62TsPfJHJyckvV5Zai5U/GAIgc5/SV9m5iMaLp7yxQ5r10WBlhqtKfRbyoBsX w09+dp4fpmlbIa2I+RMctk1wa3CsPfC08XZlwtYDV2bD+Wrokg9Ae+y8h79LoXc+VAM4/cAqdnv 1JpUtPLcSWQVUaMlDtmbxLClNZ9a0kX0eE9x2S8WKJGdXDufagU2aK6q1ucffWUXYQmjE8aDs8D PRpkPcAvMQ9wBpYqpYSzsay+nDEuArp5Ea4vVsVW/IklLOyQc= X-Received: by 2002:a05:6a00:6f12:b0:845:b735:5aa with SMTP id d2e1a72fcca58-845b73509a2mr5010634b3a.47.1782462578575; Fri, 26 Jun 2026 01:29:38 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-845a40d234esm6708789b3a.29.2026.06.26.01.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 01:29:38 -0700 (PDT) From: phucduc.bui@gmail.com To: Mark Brown , Liam Girdwood , Cezary Rojewski Cc: Jaroslav Kysela , Takashi Iwai , Peter Ujfalusi , Bard Liao , Kai Vehmanen , Pierre-Louis Bossart , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH v4 3/5] ASoC: intel: atom: Use __free(kfree) for stream pointer Date: Fri, 26 Jun 2026 15:29:02 +0700 Message-ID: <20260626082904.32344-4-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260626082904.32344-1-phucduc.bui@gmail.com> References: <20260626082904.32344-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc Declare 'stream' with __free(kfree) so it is automatically freed when leaving scope. This allows direct returns from error paths and removes the explicit kfree(stream) call. Set 'stream' to NULL after ownership has been transferred to runtime->private_data to prevent it from being freed on the success path. This cleanup is a preparation step for upcoming locking changes. Signed-off-by: bui duc phuc --- Changes in v4: - Add cleanup.h include where needed. - update commit message sound/soc/intel/atom/sst-mfld-platform-pcm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index f074af2499c8..67506a718158 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -11,6 +11,7 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -304,7 +305,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, { int ret_val = 0; struct snd_pcm_runtime *runtime = substream->runtime; - struct sst_runtime_stream *stream; + struct sst_runtime_stream *stream __free(kfree) = NULL; stream = kzalloc_obj(*stream); if (!stream) @@ -330,7 +331,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, ret_val = power_up_sst(stream); if (ret_val < 0) - goto out_power_up; + return ret_val; /* * Make sure the period to be multiple of 1ms to align the @@ -347,12 +348,19 @@ static int sst_media_open(struct snd_pcm_substream *substream, snd_pcm_hw_constraint_step(substream->runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, 2); - return snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); + ret_val = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + + if (ret_val < 0) + return ret_val; + + stream = NULL; + + return ret_val; + out_ops: mutex_unlock(&sst_lock); -out_power_up: - kfree(stream); + return ret_val; } -- 2.43.0