From 0e1e305db1b00f56f7835fc8edde5ea7d2b5a2c0 Mon Sep 17 00:00:00 2001 From: 9000h <3009073+9000h@users.noreply.github.com> Date: Sat, 9 Feb 2019 11:57:37 +0100 Subject: [PATCH 1/2] fix kernel oops --- vtunerc_ctrldev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vtunerc_ctrldev.c b/vtunerc_ctrldev.c index 6d0f05c..9f1caf2 100644 --- a/vtunerc_ctrldev.c +++ b/vtunerc_ctrldev.c @@ -179,7 +179,7 @@ static long vtunerc_ctrldev_ioctl(struct file *file, unsigned int cmd, switch (cmd) { case VTUNER_SET_NAME: dprintk(ctx, "msg VTUNER_SET_NAME\n"); - len = strlen((char *)arg) + 1; + len = sizeof((char *)arg); ctx->name = kmalloc(len, GFP_KERNEL); if (ctx->name == NULL) { printk(KERN_ERR "vtunerc%d: no memory\n", ctx->idx); From 8fcb8463be7d80bbbb7d9375a240581f46719e34 Mon Sep 17 00:00:00 2001 From: 9000h <3009073+9000h@users.noreply.github.com> Date: Sat, 9 Feb 2019 12:03:58 +0100 Subject: [PATCH 2/2] fix kernel oops --- vtunerc_ctrldev.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vtunerc_ctrldev.c b/vtunerc_ctrldev.c index 9f1caf2..44d5f26 100644 --- a/vtunerc_ctrldev.c +++ b/vtunerc_ctrldev.c @@ -169,6 +169,7 @@ static long vtunerc_ctrldev_ioctl(struct file *file, unsigned int cmd, { struct vtunerc_ctx *ctx = file->private_data; int len, i, vtype, ret = 0; + char buf[20]; if (ctx->closing) return -EINTR; @@ -207,22 +208,24 @@ static long vtunerc_ctrldev_ioctl(struct file *file, unsigned int cmd, case VTUNER_SET_TYPE: dprintk(ctx, "msg VTUNER_SET_TYPE\n"); - if (strcasecmp((char *)arg, "DVB-S") == 0) { + len = sizeof((char *)arg); + copy_from_user(buf, (char *)arg, len); + if (strcasecmp(buf, "DVB-S") == 0) { vtype = VT_S; printk(KERN_NOTICE "vtunerc%d: setting DVB-S tuner vtype\n", ctx->idx); } else - if (strcasecmp((char *)arg, "DVB-S2") == 0) { + if (strcasecmp(buf, "DVB-S2") == 0) { vtype = VT_S2; printk(KERN_NOTICE "vtunerc%d: setting DVB-S2 tuner vtype\n", ctx->idx); } else - if (strcasecmp((char *)arg, "DVB-T") == 0) { + if (strcasecmp(buf, "DVB-T") == 0) { vtype = VT_T; printk(KERN_NOTICE "vtunerc%d: setting DVB-T tuner vtype\n", ctx->idx); } else - if (strcasecmp((char *)arg, "DVB-C") == 0) { + if (strcasecmp(buf, "DVB-C") == 0) { vtype = VT_C; printk(KERN_NOTICE "vtunerc%d: setting DVB-C tuner vtype\n", ctx->idx);