Re: [PATCH] nouveau/dmem: handle kcalloc() allocation failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 03 Mar 2024, Timur Tabi <timur@xxxxxxxxxx> wrote:
> On Sun, Mar 3, 2024 at 4:46 AM Duoming Zhou <duoming@xxxxxxxxxx> 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




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux