[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dfa57d3c-6aa0-d771-8c78-91ec0c42c7b5@gmail.com>
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