From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 E8B8533CE9A for ; Fri, 8 May 2026 08:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778228705; cv=none; b=Dcu+w5vUw3wKRwTtBtXDeDtfYZbdPIiT3DEWSyVEKcWVrWThQzSFP08d7RfHTuNAx5ZxIN5RGQMW8Z9gfMidk4P+b+SnO9KRJ93OrIW54ntr64JkEp1FHnDzPpQpng+8YkGJYME1+qpeq26pa2pMQKRZ9/fCCvGCC16E/DxN/tE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778228705; c=relaxed/simple; bh=9uSnMjvrm/Jttn2V1jc2IicwVX9YLiV51NBUx+ilPew=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZGTsUxH3tDvr6OPwEzkvoOg9MSD3WZCthcwPpNOZ5J/1G3ERKpjqZeogneNeglKlojL876OicnQF8xcfBya72dc6Ypcw6Xz4irUEyswg87iHXVaoV5Z7xw8ntbwZWHrE97yoxET385NQcdS9wDoGPL1WNUSwir+DKypQwL/VfaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=aOtTsVrh; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aOtTsVrh" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-449d6c68ed8so1401813f8f.0 for ; Fri, 08 May 2026 01:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778228702; x=1778833502; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=rwE7BJvWtahw54nz5IvQHifhD+k5SwKsx8/B0OTIwHo=; b=aOtTsVrhc8QZbHXHy6qZhckajNH2S9UkgVwu59stjhEKyuM04nrgk1lXHVKNTvXQOM TrY0K5O6TAHyDDtqi3IxFKT2lgAIC15JKCIHC78XzLIlE16SOIVpXnpOAaAd9M6mUI/N 45wrK8i+lLp7+fcESwb1nSIka8JjRXA8X7s2pT+B3458CC0wLzjYW9aRXAGq1vWpNcbZ gTWy05TkbENbw1ScPNMmqqRJV1ra6+cmzJEgW0tY2M5+jY5wkyM49Iv9YkhJ4GR41F4X UVQDDcNqng2K+x+eoZ6aU25mXJlOvqQX5Eg5eZAt4hrXIk8xpP9TwQMPrkJqUDkjz8EC WSug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778228702; x=1778833502; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rwE7BJvWtahw54nz5IvQHifhD+k5SwKsx8/B0OTIwHo=; b=VfkpRAHPUu+bruOsR5rDr+o85NTqPQ+AQeBuPfQ8WhZiyccTVVBabKIAkxeZ++twCz 6hm7iEffMHlMNfewJLkcvsGARaZ/Ipwd9qO7C3rFl+5JKkWZpBwakrZFL3HqYQCjwrop qHDED4gJuey4nTuC5NSbt9I9T6QI8cN7Sd4Ysll3kQ4W9xGIgUnloLF/Q7S/xNJwl00s /RoouEWEbvTd3HYwGGhdoTLyjBmH8GsUHq8Tnj5G/k76s4zaM0kd/6Il8lDoJ9nlw1/J iB6K2ivrvx1sdkrHeIAGTl7H5wjQl40nqSHHJvVer285c6FkbmwEt1dxn5a0R5w+xtPE U/vw== X-Forwarded-Encrypted: i=1; AFNElJ/YiH5HReUmybB4r3Jpfi257GxeT19nOGlBSruxgIesD6kmHnvzFN8KzgtHtRRACyI3DCnkT5sK9Lqlj6M=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0nF6X86Q6adZbUfmuEV5SeJi6KOXcWGom7NqXdmPr+NNwvmtL /z1Up94zXp9hNYSCjvGflqziiwV7kOE9cYCD0CO1F9uCYWHNIq8uZ0oO0K9udv5VGIE= X-Gm-Gg: Acq92OGHr3/tp92Ac4O9QzSvvqG7uLO8fzZ+d0lF+2m4csxGSntp72nR3U4UWQn8st1 D4Xa3Nh4rZgQiw2ycVzAXcxDFLVfTo1g9XlqA7rfrIpiQixN2MojevSdLe8D09lTwYW4XndSxd8 xCaEiElxCvt5tSf6SNonKBROyFgCNqA/cpgzBH7A9rNfbB8rGJQ8kvwjtj3/vIvBwbpUTvTEjDm pAfbYHa5IiIuLvExykxG5IKi3MZU/awkgI/d6d+EulT8N+2J5ALMsuRTNdAH3OwbEj4UyfX/7F7 eofY0EOIR0p4Y7g6G0jmcszbDZqd9wtAcWHnRK7XvBn1K5AmoOvaOpfcalFhhFBgLsRdXDuFQV0 UbZCML9CQ5IFWVl8eZSJvCV4e5I8qxQsZFFWSy90x/GofV5n+IJkPh79qdsWnxG8mxi1Pb74DBN jl//AZRKOZ1np9QWwz3QNDFNfEPYs8 X-Received: by 2002:a05:6000:1281:b0:451:c239:d3a2 with SMTP id ffacd0b85a97d-451c239d401mr11763043f8f.3.1778228702242; Fri, 08 May 2026 01:25:02 -0700 (PDT) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4548e6a5b65sm2493295f8f.8.2026.05.08.01.25.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 May 2026 01:25:01 -0700 (PDT) Message-ID: Date: Fri, 8 May 2026 09:25:00 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] coresight: fix missing error code when trace ID is invalid To: Jie Gan Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Suzuki K Poulose , Mike Leach , Leo Yan , Alexander Shishkin , Tingwei Zhang References: <20260508-fix-trace-id-error-v1-1-5f11a5456fdf@oss.qualcomm.com> Content-Language: en-US From: James Clark In-Reply-To: <20260508-fix-trace-id-error-v1-1-5f11a5456fdf@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 08/05/2026 6:45 am, Jie Gan wrote: > When coresight_path_assign_trace_id() fails to allocate a valid trace > ID, the code jumps to err_path without setting ret to an error value. > This causes coresight_enable_sysfs() to return 0 (success) to the > caller even though no trace session was started. > > Set ret = -EINVAL before the goto so that callers receive a proper > error code. > > Fixes: d87d76d823d1 ("Coresight: Allocate trace ID after building the path") > Signed-off-by: Jie Gan > --- > drivers/hwtracing/coresight/coresight-sysfs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c > index d2a6ed8bcc74..c9338c783540 100644 > --- a/drivers/hwtracing/coresight/coresight-sysfs.c > +++ b/drivers/hwtracing/coresight/coresight-sysfs.c > @@ -195,42 +195,44 @@ int coresight_enable_sysfs(struct coresight_device *csdev) > */ > if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE) > csdev->refcnt++; > goto out; > } > > sink = coresight_find_activated_sysfs_sink(csdev); > if (!sink) { > ret = -EINVAL; > goto out; > } > > path = coresight_build_path(csdev, sink); > if (IS_ERR(path)) { > pr_err("building path(s) failed\n"); > ret = PTR_ERR(path); > goto out; > } > > coresight_path_assign_trace_id(path, CS_MODE_SYSFS); > - if (!IS_VALID_CS_TRACE_ID(path->trace_id)) > + if (!IS_VALID_CS_TRACE_ID(path->trace_id)) { > + ret = -EINVAL; > goto err_path; > + } > > ret = coresight_enable_path(path, CS_MODE_SYSFS); > if (ret) > goto err_path; > > ret = coresight_enable_source_sysfs(csdev, CS_MODE_SYSFS, path); > if (ret) > goto err_source; > > switch (subtype) { > case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC: > /* > * When working from sysFS it is important to keep track > * of the paths that were created so that they can be > * undone in 'coresight_disable()'. Since there can only > * be a single session per tracer (when working from sysFS) > * a per-cpu variable will do just fine. > */ > cpu = source_ops(csdev)->cpu_id(csdev); > per_cpu(tracer_path, cpu) = path; > > --- > base-commit: 17c7841d09ee7d33557fd075562d9289b6018c90 > change-id: 20260508-fix-trace-id-error-dbfdd4d8f2d1 > > Best regards, Reviewed-by: James Clark