lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260209112819.GL3529712@e132581.arm.com>
Date: Mon, 9 Feb 2026 11:28:19 +0000
From: Leo Yan <leo.yan@....com>
To: James Clark <james.clark@...aro.org>
Cc: coresight@...ts.linaro.org, linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Suzuki K Poulose <suzuki.poulose@....com>,
	Mike Leach <mike.leach@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Mathieu Poirier <mathieu.poirier@...aro.org>,
	Mao Jinlong <quic_jinlmao@...cinc.com>
Subject: Re: [PATCH v3 8/8] coresight: Unify error handling in
 coresight_register()

On Tue, Feb 03, 2026 at 11:15:55AM +0000, James Clark wrote:

[...]

> > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> > index 955af43010446803030973c72f07315492b2fcf3..65cf975493c86de42515845147d90497aa20c595 100644
> > --- a/drivers/hwtracing/coresight/coresight-core.c
> > +++ b/drivers/hwtracing/coresight/coresight-core.c
> > @@ -1326,7 +1326,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
> >   {
> >   	int ret;
> >   	struct coresight_device *csdev;
> > -	bool registered = false;
> >   	csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
> >   	if (!csdev) {
> > @@ -1380,7 +1379,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
> >   		 * All resources are free'd explicitly via
> >   		 * coresight_device_release(), triggered from put_device().
> >   		 */
> > -		goto out_unlock;
> > +		mutex_unlock(&coresight_mutex);
> > +		goto err_out;
> 
> I'm not sure if replacing the "registered" system with extra calls to unlock
> is necessarily better. I think the whole point of out_unlock was to have a
> single call to unlock so it couldn't be forgotten or didn't need to be
> duplicated.

The motivation for this patch is to use out_unlock as a central point
for releasing resources via coresight_unregister().

The tricky case is a device_register() failure.  Since the device is not
successfully registered, there is no need to call coresight_unregister()
to release bus resources.  However, the mutex and platform data still
need to be released.  The code here unlocks and jumps to err_out to
release the platform data.

> Probably a better way to clean this up would be to pull out a function for
> all the stuff that needs to be locked and use guard(). Then do the stuff
> that doesn't need to be locked after that function. Either way it doesn't
> look wrong.

If so, although locking is not a concern, the device_register() failures
still need to release platform data particularly.  That means we still
need extra flag (or returned error) to indicate if it is a
device_register() failure.

I understand we don't want multiple places for mutex release.  It is
not bad to keep the "registered" flag and drop this patch.

Thanks,
Leo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ