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]
Date:   Wed, 24 Mar 2021 00:29:09 +0300
From:   Dmitry Osipenko <digetx@...il.com>
To:     Minchan Kim <minchan@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-mm <linux-mm@...ck.org>, LKML <linux-kernel@...r.kernel.org>,
        gregkh@...uxfoundation.org, surenb@...gle.com, joaodias@...gle.com,
        jhubbard@...dia.com, willy@...radead.org
Subject: Re: [PATCH v5] mm: cma: support sysfs

24.03.2021 00:19, Dmitry Osipenko пишет:
>> +		if (!kobj)
>> +			goto out;
>> +
>> +		kobj->cma = cma;
>> +		cma->kobj = kobj;
>> +		if (kobject_init_and_add(&cma->kobj->kobj, &cma_ktype,
>> +					 cma_kobj_root, "%s", cma->name)) {
>> +			kobject_put(&cma->kobj->kobj);
>> +			goto out;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +out:
>> +	kobject_put(cma_kobj_root);
>> +
>> +	return -ENOMEM;
> kobject_init_and_add returns a error code, it could be different from
> ENOMEM. Won't hurt to propagate the proper error code.
> 

I think it will be cleaner to write it like this:

		cma_kobj = kzalloc(sizeof(*cma_kobj), GFP_KERNEL);
		if (!cma_kobj) {
			kobject_put(cma_kobj_root);
			return -ENOMEM;
		}

		cma_kobj->cma = cma;

		err = kobject_init_and_add(&cma_kobj->kobj, &cma_ktype,
					   cma_kobj_root, "%s", cma->name);		   
		if (err) {
			kobject_put(&cma_kobj->kobj);
			kobject_put(cma_kobj_root);
			return err;
		}
	}

	return 0;
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ