lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fbfea2a1-71e7-4572-ada2-0d4315c97e91@wanadoo.fr>
Date: Thu, 16 Jan 2025 19:29:22 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: devnull+fnkl.kernel.gmail.com@...nel.org
Cc: alyssa@...enzweig.io, asahi@...ts.linux.dev, conor+dt@...nel.org,
 devicetree@...r.kernel.org, dmitry.torokhov@...il.com,
 fnkl.kernel@...il.com, j@...nau.net, krzk+dt@...nel.org,
 linux-arm-kernel@...ts.infradead.org, linux-input@...r.kernel.org,
 linux-kernel@...r.kernel.org, marcan@...can.st, neal@...pa.dev,
 robh@...nel.org, rydberg@...math.org, sven@...npeter.dev
Subject: Re: [PATCH v4 2/4] input: apple_z2: Add a driver for Apple Z2
 touchscreens

>> +static int apple_z2_probe(struct spi_device *spi)
>> +{
>> +    struct device *dev = &spi->dev;
>> +    struct apple_z2 *z2;
>> +    int error;
>> +
>> +    z2 = devm_kzalloc(dev, sizeof(*z2), GFP_KERNEL);
>> +    if (!z2)
>> +        return -ENOMEM;
>> +
>> +    z2->tx_buf = devm_kzalloc(dev, sizeof(struct 
>> apple_z2_read_interrupt_cmd), GFP_KERNEL);
>> +    z2->rx_buf = devm_kzalloc(dev, 4096, GFP_KERNEL);
> 
> This will allocate 8192 bytes because of the way the allocator works.
> It needs around 40 bytes for the devm stuff + 4096 requested. So 
> rounding rules will allocate 8192 bytes.
> 
> So either you could allocate "for free" much more space, or you could 
> allocate (and document...)
>      z2->rx_buf = devm_kzalloc(dev, 4096 - sizeof(struct devres), 
> GFP_KERNEL);
> 
> or have an explicit devm_add_action_or_reset() that would require less 
> memory, but would add some LoC.
> 

or leave it as-is, of course ;-)

> 
> See https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/base/ 
> devres.c#L97
> 



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ