Skip to content

Commit 17f5eeb

Browse files
committed
Input: ili210x - use kvmalloc() to allocate buffer for firmware update
Allocating a contiguous buffer of 64K may fail if memory is sufficiently fragmented, and may cause OOM kill of an unrelated process. However we do not need to have contiguous memory. We also do not need to zero out the buffer since it will be overwritten with firmware data. Switch to using kvmalloc() instead of kzalloc(). Link: https://lore.kernel.org/r/20240609234757.610273-1-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent f2845b4 commit 17f5eeb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/input/touchscreen/ili210x.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static int ili251x_firmware_to_buffer(const struct firmware *fw,
597597
* once, copy them all into this buffer at the right locations, and then
598598
* do all operations on this linear buffer.
599599
*/
600-
fw_buf = kzalloc(SZ_64K, GFP_KERNEL);
600+
fw_buf = kvmalloc(SZ_64K, GFP_KERNEL);
601601
if (!fw_buf)
602602
return -ENOMEM;
603603

@@ -627,7 +627,7 @@ static int ili251x_firmware_to_buffer(const struct firmware *fw,
627627
return 0;
628628

629629
err_big:
630-
kfree(fw_buf);
630+
kvfree(fw_buf);
631631
return error;
632632
}
633633

@@ -870,7 +870,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
870870
ili210x_hardware_reset(priv->reset_gpio);
871871
dev_dbg(dev, "Firmware update ended, error=%i\n", error);
872872
enable_irq(client->irq);
873-
kfree(fwbuf);
873+
kvfree(fwbuf);
874874
return error;
875875
}
876876

0 commit comments

Comments
 (0)