From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 5DECC2E5B05 for ; Mon, 15 Dec 2025 09:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765789331; cv=none; b=AQA0DypemJbLiUPwxor2ygJbXRa+OyO7U2allM4ZCX0CBtiJ0lxhw0bSalwz5RJ9zH182RH0PJ1I1LaAK9aTFbMPq+xgqjBLQFZN8LjU4HMpjP6rchCVHD9NOsQbEHVpX12bZ02QUpL/ONaV4L1RRoQbuqI2px8oRiAl/YsBjfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765789331; c=relaxed/simple; bh=9NvkoFw7U3ArevfZL6/5aLW0bkMGw3tc/YoZtkn4VXk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GIY527sqvU2/s4wW4sdYP5kqX3w9VRqyVfHPevCsw81rUp8lAQdNVAeUpQLs8fwHk3InvjdJflR3hhdG/owmdvUVHn8VP/S/d2TdDsvHRGH1EDzDBqHJFTVnTJ6Jw9xCt/PKqxLshztO77kEXmQAi8WDXtb6cABrQatXjzAQ+0g= 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=TQ3dBEoL; arc=none smtp.client-ip=209.85.208.45 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="TQ3dBEoL" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-640c1fda178so6421414a12.1 for ; Mon, 15 Dec 2025 01:02:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765789327; x=1766394127; 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=/eh2Jk7y1LUL7tcgTyarCIDEPQpluVmFaeTv2vZoA4M=; b=TQ3dBEoLbpTz9tCpx1G0RK0KHklLl27Jzb3sIZpioiX9/lPVtjiSjreNXUAIwRveha s+BptPI6sWrN3C86NfhPK3ckYqm5lut1RbrOhZYcLk/w3jrkSaZ7RhIHEnAg1Va0PO/s KfI0VUqKkqcxwzQOxEdsMb1xjoyKioVaF5s7o4XRekoJXer+unNKnBB9Ei2M56pvMv7y yZgn2ChlNrzDmWjLumR4wymoCl/BU3rLr1wQrS+nZqMJmmgVTWj3QqDVjF8W0dYiLmUP P9SqNj18Ns3GYP1F0NT5d08s1J0oWLCRT09m6WLGf6Pa92Am6y131hsdwKPQdszVdm9E DQxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765789327; x=1766394127; 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=/eh2Jk7y1LUL7tcgTyarCIDEPQpluVmFaeTv2vZoA4M=; b=Ts2O+8ERCT+FazftyACWVZPy2nn5vykbGkTJuQxpMRZHipArBy1WQagb3LElir07f7 /KuL9feVrJtBD+ha9LkxYogEmgWv18sWS1aRgeyZfPqYuTG4UMoAbpIay1ShD8AfQDVN Ej/csCp38set5jDBP5liJ/0x5qlIMLu5WAaBJVQBcBSDT4HHyCykfvR5YWNK4eG27rux 9qa5dg5hbTnEfZDGwILFsEruE7he9U6GFu/FdQY78iwZEdc/fzT874Py6a4OxLeLzA+e Eli2cTs8C/5/PBtIugsTT7ma7vtfFU9KiB7ibd4x+zs5YcFBuzOaoRSpukJv3oZxZzkJ ylwg== X-Forwarded-Encrypted: i=1; AJvYcCVzqGOa6QQtbyVV52gRveP0+iuNpufZswDW1ycYUgaRHfbmDDDEVGoa8vvqfwrzRQ682RJ39nA7QaO1jjs=@vger.kernel.org X-Gm-Message-State: AOJu0YymZZY1SENtm6+BNk10KyH2Nq4+LnYX31y+6eSCHc81pO/BhSox j2V1mpLt4E1FxjHRsAruRha3HK/akbb6YAIFT68e9BBtzFTEHZLdyHJVLIwTG2OYvqA= X-Gm-Gg: AY/fxX5TD4M2/IyXZ8ya/p+WAL2QckbGlHwsIQhuA/XVDqWgUn3KdNvscj491PGxvk8 D3KP9htULYh0c8+i3zfo/bJdRRhd0XkeBB1IxdfYkmi3/YiOP1QgzKkdUWRvX96y1UltN7iv6zb GwwdfAn+yBVkf9GENa85eLYzmmRKmVM6a5omvMjH5VneB3JZ2d3YzsLNdcz/dP4wvtMLOgrhtnV wm/0I+txgQIJ27MnZ8jDT/q9UAyhdYhlYLomMqczq/OUxOL9TETRkYdnwpy1aTGrdbGm5EH2iSV /HPtBVAR9mRhYmsahFXlb7oY8kyw9IGrHV7J4qCVIoGycdSPwf+QW1DxQBIVvolH3JWJeaBkSN3 GeJO7GaYj8+LHJH3DY+F3WeiJVn0cmBL+1ktM49jmP1SP/RsiorblqYHoJ1GTukP3m1fhwQ04yb 45pgBgkM+nqEbg7Selv6lN X-Google-Smtp-Source: AGHT+IG4myQfras1/40xDmXOQgpwgiM3Ljs8/6uploYCUZ16zAD9bEd9YTmSTzDXHafRBREFjId5kg== X-Received: by 2002:a05:6402:1446:b0:640:ca0a:dc1c with SMTP id 4fb4d7f45d1cf-6499b16e791mr10050760a12.7.1765789326445; Mon, 15 Dec 2025 01:02:06 -0800 (PST) Received: from [192.168.0.108] ([130.185.218.160]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64981fa5514sm12907579a12.0.2025.12.15.01.02.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Dec 2025 01:02:06 -0800 (PST) Message-ID: Date: Mon, 15 Dec 2025 11:02:08 +0200 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 v2 RESEND] coresight: etm-perf: Fix reference count leak in etm_setup_aux To: Ma Ke , Leo Yan Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, stable@vger.kernel.org, suzuki.poulose@arm.com, mike.leach@linaro.org, alexander.shishkin@linux.intel.com, mathieu.poirier@linaro.org References: <20251215022709.17220-1-make24@iscas.ac.cn> Content-Language: en-US From: James Clark In-Reply-To: <20251215022709.17220-1-make24@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 15/12/2025 04:27, Ma Ke wrote: > In etm_setup_aux(), when a user sink is obtained via > coresight_get_sink_by_id(), it increments the reference count of the > sink device. However, if the sink is used in path building, the path > holds a reference, but the initial reference from > coresight_get_sink_by_id() is not released, causing a reference count > leak. We should release the initial reference after the path is built. > > Found by code review. > > Cc: stable@vger.kernel.org > Fixes: 0e6c20517596 ("coresight: etm-perf: Allow an event to use different sinks") > Signed-off-by: Ma Ke > --- > Changes in v2: > - modified the patch as suggestions. I think Leo's comment on the previous v2 is still unaddressed. But releasing it in coresight_get_sink_by_id() would make it consistent with coresight_find_csdev_by_fwnode() and prevent further mistakes. It also leads me to see that users of coresight_find_device_by_fwnode() should also release it, but only one out of two appears to. James > --- > drivers/hwtracing/coresight/coresight-etm-perf.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > index 17afa0f4cdee..56d012ab6d3a 100644 > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > @@ -454,6 +454,11 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, > goto err; > > out: > + if (user_sink) { > + put_device(&user_sink->dev); > + user_sink = NULL; > + } > + > return event_data; > > err: