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] [day] [month] [year] [list]
Date:   Sun, 28 Apr 2019 18:16:54 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     "Tobin C. Harding" <tobin@...nel.org>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kobject: Improve docs for kobject_add/del

On Sun, Apr 28, 2019 at 10:48:10AM +1000, Tobin C. Harding wrote:
> There is currently some confusion on how to wind back
> kobject_init_and_add() during the error paths in code that uses this
> function.
> 
> Add documentation to kobject_add() and kobject_del() to help clarify the
> usage.
> 
> Signed-off-by: Tobin C. Harding <tobin@...nel.org>
> ---
> 
> The assumption is that this is the correct usage, and that's what I've
> tried to document.  Is this correct?
> 
> void fn(void)
> {
> 	int ret;
> 
> 	ret = kobject_init_and_add(kobj, ktype, NULL, "foo");
> 	if (ret) {
> 		kobject_put(kobj);
> 		return -1;

Don't make up error numbers, use a real one :)

> 	}
> 
> 	ret = some_init_fn();
> 	if (ret)
> 		goto err;
> 
> 	ret = some_other_init_fn();
> 	if (ret)
> 		goto other_err;
> 
> 	kobject_uevent(kobj, KOBJ_ADD);
> 	return 0;
> 
> other_err:
> 	other_clean_up_fn();
> err:
> 	kobject_del(kobj);
> 	return ret;
> }

Yes, this looks correct.

I've queued both of these patches up now, thanks!

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ