Commit b718fbfe authored by Kent Gibson's avatar Kent Gibson Committed by Bartosz Golaszewski
Browse files

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: default avatarKent Gibson <warthog618@gmail.com>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent ede7511e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1723,7 +1723,7 @@ static void linereq_free(struct linereq *lr)
	kfifo_free(&lr->events);
	kfree(lr->label);
	gpio_device_put(lr->gdev);
	kfree(lr);
	kvfree(lr);
}

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)
	if (ret)
		return ret;

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