From: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
To: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
"Intel graphics driver community testing & development"
<intel-gfx@lists.freedesktop.org>,
"Sebastian Brzezinka" <sebastian.brzezinka@intel.com>
Cc: "Martin Hodo" <martin.hodo@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Simona Vetter" <simona.vetter@ffwll.ch>,
stable@vger.kernel.org
Subject: Re: [PATCH] drm/i915: Return NULL on error in active_instance
Date: Wed, 24 Jun 2026 12:29:06 +0200 [thread overview]
Message-ID: <DJH7JDWM7XPO.2G0OQ6XWLI13Q@intel.com> (raw)
In-Reply-To: <178229668435.102045.3320967434448969310@jlahtine-mobl>
On Wed Jun 24, 2026 at 12:24 PM CEST, Joonas Lahtinen wrote:
> Quoting Sebastian Brzezinka (2026-06-24 12:27:07)
>> Hi,
>> On Wed Jun 24, 2026 at 11:09 AM CEST, Joonas Lahtinen wrote:
>> > Avoid returning &node->base when node is NULL due to OOM
>> > during GFP_ATOMIC allocation.
>> >
>> > Discovered using AI-assisted static analysis confirmed by
>> > Intel Product Security.
>
> <SNIP>
>
>> > +++ b/drivers/gpu/drm/i915/i915_active.c
>> > @@ -318,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx)
>> > */
>> > node = kmem_cache_alloc(slab_cache, GFP_ATOMIC);
>> > if (!node)
>> > - goto out;
>> > + goto err;
>> just a nit: this jump is not neccesery, you could return early.
>
> We specifically want to embrace the onion error handling idiom with goto
> rather than doing the spinlock release inline here.
>
> Preferred error handling should look more like:
>
> if (!try_lock(lock))
> goto err;
>
> mem = alloc();
> if (!mem)
> goto err_lock;
>
> if (!bla_bla(mem, bar))
> goto err_mem;
>
> ...
>
> err_mem:
> free(mem);
> err_lock:
> unlock(lock);
> err:
> return ret;
>
> Rather than:
>
> if (!try_lock(lock))
> return ret;
>
> mem = alloc();
> if (!mem)
> {
> unlock(lock);
> return ret;
> }
>
> if (!bla_bla(mem, bar))
> {
> free(mem);
> unlock(lock);
> return ret;
> }
>
> ...
>
> Regards, Joonas
Good to know, thanks for the explanation.
--
Best regards,
Sebastian
next prev parent reply other threads:[~2026-06-24 10:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
2026-06-24 9:20 ` Sebastian Brzezinka
2026-06-24 9:27 ` Sebastian Brzezinka
2026-06-24 10:24 ` Joonas Lahtinen
2026-06-24 10:29 ` Sebastian Brzezinka [this message]
2026-06-24 9:54 ` Maarten Lankhorst
2026-06-24 11:25 ` Joonas Lahtinen
2026-06-24 12:59 ` Andi Shyti
2026-06-25 6:03 ` Joonas Lahtinen
2026-06-25 8:50 ` [PATCH] drm/i915: Return NULL on error in active_instanceg Andi Shyti
2026-06-25 12:11 ` Joonas Lahtinen
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=DJH7JDWM7XPO.2G0OQ6XWLI13Q@intel.com \
--to=sebastian.brzezinka@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=joonas.lahtinen@linux.intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=martin.hodo@intel.com \
--cc=simona.vetter@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox