From: "Danilo Krummrich" <dakr@kernel.org>
To: <lyude@redhat.com>
Cc: liupeng <liupeng01@kylinos.cn>,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
simona@ffwll.ch, linux@roeck-us.net, nouveau@karolherbst.de,
bskeggs@redhat.com, dri-devel@lists.freedesktop.org,
nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-hwmon@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3] drm/nouveau: Fix memory leaks in debugfs and hwmon init error paths
Date: Fri, 09 Oct 2026 23:40:52 +0200 [thread overview]
Message-ID: <DM0MU0O43EB9.3EEKZ4C2IUP9J@kernel.org> (raw)
In-Reply-To: <25778dca265f58185917c5948490e76184c778d3.camel@redhat.com>
On Fri Oct 9, 2026 at 11:35 PM CEST, lyude wrote:
> Reviewed-by: Lyude Paul <lyude@redhat.com>
>
> Will push to drm-misc-fixes in a moment
Please wait, those are two unrelated fixes with two different Fixes: tags, so
those should be two separate patches.
I'm also not sure this is -fixes material. A memory leak in an unwind path for
-rc7 feels wrong.
Thanks,
Danilo
> On Fri, 2026-10-09 at 19:51 +0800, liupeng wrote:
>> In nouveau_debugfs_init(), if nvif_object_ctor() fails, the
>> previously
>> allocated drm->debugfs is leaked because the function returns the
>> error code directly.
>>
>> In nouveau_hwmon_init(), if hwmon_device_register_with_info() fails,
>> the allocated hwmon structure is leaked because the function returns
>> the error code directly.
>>
>> Fix both by freeing the allocated memory and clearing the pointer on
>> the error paths.
>>
>> Fixes: b126a200e9db ("drm/nouveau/debugfs: we need a ctrl object for
>> debugfs")
>> Fixes: b9ed919f1c8f ("drm/nouveau/drm/pm: remove everything except
>> the hwmon interfaces to THERM")
>> Cc: stable@vger.kernel.org
>> Reviewed-by: Lyude Paul <lyude@redhat.com>
>> Signed-off-by: liupeng <liupeng01@kylinos.cn>
>> ---
>> Changes in v3:
>> - Drop the extra return in nouveau_debugfs_init() as suggested by
>> Lyude.
>> - Add Reviewed-by tag.
>>
>> drivers/gpu/drm/nouveau/nouveau_debugfs.c | 14 +++++++++++---
>> drivers/gpu/drm/nouveau/nouveau_hwmon.c | 2 ++
>> 2 files changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> index 47d5579c568d..338421e52f69 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> @@ -295,13 +295,21 @@ nouveau_drm_debugfs_init(struct drm_minor
>> *minor)
>> int
>> nouveau_debugfs_init(struct nouveau_drm *drm)
>> {
>> + int ret;
>> +
>> drm->debugfs = kzalloc_obj(*drm->debugfs);
>> if (!drm->debugfs)
>> return -ENOMEM;
>>
>> - return nvif_object_ctor(&drm->client.device.object,
>> "debugfsCtrl", 0,
>> - NVIF_CLASS_CONTROL, NULL, 0,
>> - &drm->debugfs->ctrl);
>> + ret = nvif_object_ctor(&drm->client.device.object,
>> "debugfsCtrl", 0,
>> + NVIF_CLASS_CONTROL, NULL, 0,
>> + &drm->debugfs->ctrl);
>> + if (ret) {
>> + kfree(drm->debugfs);
>> + drm->debugfs = NULL;
>> + }
>> +
>> + return ret;
>> }
>>
>> void
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> index 726397ab035d..ffbe7f542ab0 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> @@ -697,6 +697,8 @@ nouveau_hwmon_init(struct drm_device *dev)
>> if (IS_ERR(hwmon_dev)) {
>> ret = PTR_ERR(hwmon_dev);
>> NV_ERROR(drm, "Unable to register hwmon device:
>> %d\n", ret);
>> + drm->hwmon = NULL;
>> + kfree(hwmon);
>> return ret;
>> }
>>
WARNING: multiple messages have this Message-ID (diff)
From: "Danilo Krummrich" <dakr@kernel.org>
To: <lyude@redhat.com>
Cc: "liupeng" <liupeng01@kylinos.cn>,
<maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
<tzimmermann@suse.de>, <airlied@gmail.com>, <simona@ffwll.ch>,
<linux@roeck-us.net>, <nouveau@karolherbst.de>,
<bskeggs@redhat.com>, <dri-devel@lists.freedesktop.org>,
<nouveau@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<linux-hwmon@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH v3] drm/nouveau: Fix memory leaks in debugfs and hwmon init error paths
Date: Fri, 09 Oct 2026 23:40:52 +0200 [thread overview]
Message-ID: <DM0MU0O43EB9.3EEKZ4C2IUP9J@kernel.org> (raw)
In-Reply-To: <25778dca265f58185917c5948490e76184c778d3.camel@redhat.com>
On Fri Oct 9, 2026 at 11:35 PM CEST, lyude wrote:
> Reviewed-by: Lyude Paul <lyude@redhat.com>
>
> Will push to drm-misc-fixes in a moment
Please wait, those are two unrelated fixes with two different Fixes: tags, so
those should be two separate patches.
I'm also not sure this is -fixes material. A memory leak in an unwind path for
-rc7 feels wrong.
Thanks,
Danilo
> On Fri, 2026-10-09 at 19:51 +0800, liupeng wrote:
>> In nouveau_debugfs_init(), if nvif_object_ctor() fails, the
>> previously
>> allocated drm->debugfs is leaked because the function returns the
>> error code directly.
>>
>> In nouveau_hwmon_init(), if hwmon_device_register_with_info() fails,
>> the allocated hwmon structure is leaked because the function returns
>> the error code directly.
>>
>> Fix both by freeing the allocated memory and clearing the pointer on
>> the error paths.
>>
>> Fixes: b126a200e9db ("drm/nouveau/debugfs: we need a ctrl object for
>> debugfs")
>> Fixes: b9ed919f1c8f ("drm/nouveau/drm/pm: remove everything except
>> the hwmon interfaces to THERM")
>> Cc: stable@vger.kernel.org
>> Reviewed-by: Lyude Paul <lyude@redhat.com>
>> Signed-off-by: liupeng <liupeng01@kylinos.cn>
>> ---
>> Changes in v3:
>> - Drop the extra return in nouveau_debugfs_init() as suggested by
>> Lyude.
>> - Add Reviewed-by tag.
>>
>> drivers/gpu/drm/nouveau/nouveau_debugfs.c | 14 +++++++++++---
>> drivers/gpu/drm/nouveau/nouveau_hwmon.c | 2 ++
>> 2 files changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> index 47d5579c568d..338421e52f69 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
>> @@ -295,13 +295,21 @@ nouveau_drm_debugfs_init(struct drm_minor
>> *minor)
>> int
>> nouveau_debugfs_init(struct nouveau_drm *drm)
>> {
>> + int ret;
>> +
>> drm->debugfs = kzalloc_obj(*drm->debugfs);
>> if (!drm->debugfs)
>> return -ENOMEM;
>>
>> - return nvif_object_ctor(&drm->client.device.object,
>> "debugfsCtrl", 0,
>> - NVIF_CLASS_CONTROL, NULL, 0,
>> - &drm->debugfs->ctrl);
>> + ret = nvif_object_ctor(&drm->client.device.object,
>> "debugfsCtrl", 0,
>> + NVIF_CLASS_CONTROL, NULL, 0,
>> + &drm->debugfs->ctrl);
>> + if (ret) {
>> + kfree(drm->debugfs);
>> + drm->debugfs = NULL;
>> + }
>> +
>> + return ret;
>> }
>>
>> void
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> index 726397ab035d..ffbe7f542ab0 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c
>> @@ -697,6 +697,8 @@ nouveau_hwmon_init(struct drm_device *dev)
>> if (IS_ERR(hwmon_dev)) {
>> ret = PTR_ERR(hwmon_dev);
>> NV_ERROR(drm, "Unable to register hwmon device:
>> %d\n", ret);
>> + drm->hwmon = NULL;
>> + kfree(hwmon);
>> return ret;
>> }
>>
next prev parent reply other threads:[~2026-10-09 21:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 9:05 [PATCH] drm/nouveau: Fix memory leaks in debugfs and hwmon init error paths liupeng
2026-08-24 9:12 ` sashiko-bot
2026-09-17 22:10 ` lyude
2026-09-22 4:40 ` [PATCH v2] " liupeng
2026-09-22 4:40 ` liupeng
2026-09-22 4:46 ` sashiko-bot
2026-10-08 21:45 ` lyude
2026-10-08 21:45 ` lyude
2026-10-09 11:51 ` [PATCH v3] " liupeng
2026-10-09 11:51 ` liupeng
2026-10-09 12:00 ` sashiko-bot
2026-10-09 21:35 ` lyude
2026-10-09 21:35 ` lyude
2026-10-09 21:40 ` Danilo Krummrich [this message]
2026-10-09 21:40 ` Danilo Krummrich
2026-10-09 21:43 ` lyude
2026-10-09 21:43 ` lyude
2026-10-10 2:20 ` [PATCH v4 1/2] drm/nouveau: Fix memory leak in debugfs init error path liupeng
2026-10-10 2:20 ` liupeng
2026-10-10 2:20 ` [PATCH v4 2/2] drm/nouveau: Fix memory leak in hwmon " liupeng
2026-10-10 2:20 ` liupeng
2026-10-10 2:26 ` sashiko-bot
2026-10-10 2:26 ` [PATCH v4 1/2] drm/nouveau: Fix memory leak in debugfs " sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM0MU0O43EB9.3EEKZ4C2IUP9J@kernel.org \
--to=dakr@kernel.org \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=liupeng01@kylinos.cn \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nouveau@karolherbst.de \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.