[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d224c6bd-f5b1-74f6-2afc-c3d5b0519ba4@nvidia.com>
Date: Tue, 23 Mar 2021 21:47:27 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Minchan Kim <minchan@...nel.org>
CC: Andrew Morton <akpm@...ux-foundation.org>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
<gregkh@...uxfoundation.org>, <surenb@...gle.com>,
<joaodias@...gle.com>, <willy@...radead.org>, <digetx@...il.com>
Subject: Re: [PATCH v6] mm: cma: support sysfs
On 3/23/21 8:27 PM, Minchan Kim wrote:
...
>>> +static int __init cma_sysfs_init(void)
>>> +{
>>> + unsigned int i;
>>> +
>>> + cma_kobj_root = kobject_create_and_add("cma", mm_kobj);
>>> + if (!cma_kobj_root)
>>> + return -ENOMEM;
>>> +
>>> + for (i = 0; i < cma_area_count; i++) {
>>> + int err;
>>> + struct cma *cma;
>>> + struct cma_kobject *cma_kobj;
>>> +
>>> + cma_kobj = kzalloc(sizeof(*cma_kobj), GFP_KERNEL);
>>> + if (!cma_kobj) {
>>> + kobject_put(cma_kobj_root);
>>> + return -ENOMEM;
>>
>> This leaks little cma_kobj's all over the floor. :)
>
> I thought kobject_put(cma_kobj_root) should deal with it. No?
>
If this fails when i > 0, there will be cma_kobj instances that
were stashed in the cma_areas[] array. But this code only deletes
the most recently allocated cma_kobj, not anything allocated on
previous iterations of the loop.
thanks,
--
John Hubbard
NVIDIA
Powered by blists - more mailing lists