All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: <maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
	<tzimmermann@suse.de>, <airlied@gmail.com>, <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH] drm/test: drm_exec: use kzalloc() to allocate GEM objects
Date: Fri, 29 Aug 2025 13:03:35 +0200	[thread overview]
Message-ID: <DCEV0WH99TA7.2O5C0STM3MQCS@kernel.org> (raw)
In-Reply-To: <20250829075633.2306-1-dakr@kernel.org>

On Fri Aug 29, 2025 at 9:55 AM CEST, Danilo Krummrich wrote:
> diff --git a/drivers/gpu/drm/tests/drm_exec_test.c b/drivers/gpu/drm/tests/drm_exec_test.c
> index d6c4dd1194a0..d59ec3baae1d 100644
> --- a/drivers/gpu/drm/tests/drm_exec_test.c
> +++ b/drivers/gpu/drm/tests/drm_exec_test.c
> @@ -150,14 +150,22 @@ static void test_prepare(struct kunit *test)
>  static void test_prepare_array(struct kunit *test)
>  {
>  	struct drm_exec_priv *priv = test->priv;
> -	struct drm_gem_object gobj1 = { };
> -	struct drm_gem_object gobj2 = { };
> -	struct drm_gem_object *array[] = { &gobj1, &gobj2 };
> +	struct drm_gem_object *gobj1;
> +	struct drm_gem_object *gobj2;
> +	struct drm_gem_object *array[] = {
> +		(gobj1 = kzalloc(sizeof(*gobj1), GFP_KERNEL)),
> +		(gobj2 = kzalloc(sizeof(*gobj2), GFP_KERNEL)),
> +	};

Actually, I think this should use kunit_kzmalloc() instead. Unless anyone
disagrees, I'd apply the following hunk when applying the patch.

diff --git a/drivers/gpu/drm/tests/drm_exec_test.c b/drivers/gpu/drm/tests/drm_exec_test.c
index d59ec3baae1d..3a20c788c51f 100644
--- a/drivers/gpu/drm/tests/drm_exec_test.c
+++ b/drivers/gpu/drm/tests/drm_exec_test.c
@@ -153,15 +153,15 @@ static void test_prepare_array(struct kunit *test)
        struct drm_gem_object *gobj1;
        struct drm_gem_object *gobj2;
        struct drm_gem_object *array[] = {
-               (gobj1 = kzalloc(sizeof(*gobj1), GFP_KERNEL)),
-               (gobj2 = kzalloc(sizeof(*gobj2), GFP_KERNEL)),
+               (gobj1 = kunit_kzalloc(test, sizeof(*gobj1), GFP_KERNEL)),
+               (gobj2 = kunit_kzalloc(test, sizeof(*gobj2), GFP_KERNEL)),
        };
        struct drm_exec exec;
        int ret;

        if (!gobj1 || !gobj2) {
                KUNIT_FAIL(test, "Failed to allocate GEM objects.\n");
-               goto out;
+               return;
        }

        drm_gem_private_object_init(priv->drm, gobj1, PAGE_SIZE);
@@ -176,10 +176,6 @@ static void test_prepare_array(struct kunit *test)

        drm_gem_private_object_fini(gobj1);
        drm_gem_private_object_fini(gobj2);
-
-out:
-       kfree(gobj1);
-       kfree(gobj2);
 }

 static void test_multiple_loops(struct kunit *test)

  parent reply	other threads:[~2025-08-29 11:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29  7:55 [PATCH] drm/test: drm_exec: use kzalloc() to allocate GEM objects Danilo Krummrich
2025-08-29  8:00 ` Nirmoy Das
2025-08-29  8:41 ` Alice Ryhl
2025-08-29 10:54 ` Christian König
2025-08-29 11:03 ` Danilo Krummrich [this message]
2025-08-29 16:03 ` Danilo Krummrich

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=DCEV0WH99TA7.2O5C0STM3MQCS@kernel.org \
    --to=dakr@kernel.org \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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.