From: Jani Nikula <jani.nikula@linux.intel.com>
To: Timur Tabi <timur@kernel.org>, Duoming Zhou <duoming@zju.edu.cn>
Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] nouveau/dmem: handle kcalloc() allocation failure
Date: Mon, 04 Mar 2024 14:14:52 +0200 [thread overview]
Message-ID: <87y1ay42ir.fsf@intel.com> (raw)
In-Reply-To: <CAOZdJXUebAScPBjJdCbdzzA_Hmotk11bd7MvLLxe+pqS5-upHQ@mail.gmail.com>
On Sun, 03 Mar 2024, Timur Tabi <timur@kernel.org> wrote:
> On Sun, Mar 3, 2024 at 4:46 AM Duoming Zhou <duoming@zju.edu.cn> wrote:
>>
>> The kcalloc() in nouveau_dmem_evict_chunk() will return null if
>> the physical memory has run out. As a result, if we dereference
>> src_pfns, dst_pfns or dma_addrs, the null pointer dereference bugs
>> will happen.
>>
>> This patch uses stack variables to replace the kcalloc().
>
> Won't this blow the stack? And why not just test the return value of
> kcalloc?
VLAs should not be used in the kernel anymore. Building this results in
a warning due to -Wvla. See 0bb95f80a38f ("Makefile: Globally enable VLA
warning").
Error checking and propagation is the way to go.
BR,
Jani.
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-03-04 12:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 8:13 [PATCH] nouveau/dmem: handle kcalloc() allocation failure Duoming Zhou
2024-03-04 3:02 ` Timur Tabi
2024-03-04 12:14 ` Jani Nikula [this message]
2024-03-05 13:08 ` duoming
2024-03-05 13:26 ` Jani Nikula
-- strict thread matches above, loose matches on Subject: below --
2024-03-03 7:53 Duoming Zhou
2024-03-05 13:40 ` 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=87y1ay42ir.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=duoming@zju.edu.cn \
--cc=nouveau@lists.freedesktop.org \
--cc=timur@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.