Re: [PATCH v5] mm: cma: support sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux