mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-28 11:23:35 +08:00
vinput: Fix NULL pointer dereference caused by failed kzalloc allocation
When kzalloc fails to allocate memory and returns NULL, it leads to a NULL pointer dereference error later on. Add a check for the return value of kzalloc. When kzalloc fails to allocate memory, it prints an error message and returns ERR_PTR(-ENOMEM).
This commit is contained in:
parent
1e26743c30
commit
c068fa47e9
|
@ -177,6 +177,11 @@ static struct vinput *vinput_alloc_vdevice(void)
|
|||
int err;
|
||||
struct vinput *vinput = kzalloc(sizeof(struct vinput), GFP_KERNEL);
|
||||
|
||||
if (!vinput) {
|
||||
pr_err("vinput: Cannot allocate vinput input device\n");
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
try_module_get(THIS_MODULE);
|
||||
|
||||
spin_lock_init(&vinput->lock);
|
||||
|
|
Loading…
Reference in New Issue
Block a user