Skip to content

Commit e1eced6

Browse files
authored
Merge pull request #258 from visitorckw/fix-vinput
vinput: Fix multiple issue
2 parents 0a27a01 + 0a23ecd commit e1eced6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/vinput.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static ssize_t vinput_read(struct file *file, char __user *buffer, size_t count,
106106
count = len - *offset;
107107

108108
if (raw_copy_to_user(buffer, buff + *offset, count))
109-
count = -EFAULT;
109+
return -EFAULT;
110110

111111
*offset += count;
112112

@@ -177,9 +177,12 @@ static struct vinput *vinput_alloc_vdevice(void)
177177
int err;
178178
struct vinput *vinput = kzalloc(sizeof(struct vinput), GFP_KERNEL);
179179

180-
try_module_get(THIS_MODULE);
180+
if (!vinput) {
181+
pr_err("vinput: Cannot allocate vinput input device\n");
182+
return ERR_PTR(-ENOMEM);
183+
}
181184

182-
memset(vinput, 0, sizeof(struct vinput));
185+
try_module_get(THIS_MODULE);
183186

184187
spin_lock_init(&vinput->lock);
185188

0 commit comments

Comments
 (0)