Skip to content

Commit b718fbf

Browse files
warthog618Bartosz Golaszewski
authored andcommitted
gpiolib: cdev: allocate linereq using kvzalloc()
The size of struct linereq may exceed a page, so allocate space for it using kvzalloc() instead of kzalloc() to handle the case where memory is heavily fragmented and kzalloc() cannot find a sufficient contiguous region. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent ede7511 commit b718fbf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/gpio/gpiolib-cdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ static void linereq_free(struct linereq *lr)
17231723
kfifo_free(&lr->events);
17241724
kfree(lr->label);
17251725
gpio_device_put(lr->gdev);
1726-
kfree(lr);
1726+
kvfree(lr);
17271727
}
17281728

17291729
static int linereq_release(struct inode *inode, struct file *file)
@@ -1788,7 +1788,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip)
17881788
if (ret)
17891789
return ret;
17901790

1791-
lr = kzalloc(struct_size(lr, lines, ulr.num_lines), GFP_KERNEL);
1791+
lr = kvzalloc(struct_size(lr, lines, ulr.num_lines), GFP_KERNEL);
17921792
if (!lr)
17931793
return -ENOMEM;
17941794
lr->num_lines = ulr.num_lines;

0 commit comments

Comments
 (0)