From: Dan Carpenter Date: Fri, 26 Oct 2018 07:19:51 +0000 (+0300) Subject: uio: Fix an Oops on load X-Git-Tag: v3.18.127~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5221513ba055c771e15fc6618650aa105d39c4fe;p=profile%2Fwearable%2Fplatform%2Fkernel%2Flinux-3.18-exynos7270.git uio: Fix an Oops on load commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream. I was trying to solve a double free but I introduced a more serious NULL dereference bug. The problem is that if there is an IRQ which triggers immediately, then we need "info->uio_dev" but it's not set yet. This patch puts the original initialization back to how it was and just sets info->uio_dev to NULL on the error path so it should solve both the Oops and the double free. Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails") Reported-by: Mathias Thore Signed-off-by: Dan Carpenter Cc: stable Tested-by: Mathias Thore Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index db292c0..f4da749 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -841,14 +841,17 @@ int __uio_register_device(struct module *owner, if (ret) goto err_uio_dev_add_attributes; + info->uio_dev = idev; + if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) { ret = devm_request_irq(idev->dev, info->irq, uio_interrupt, info->irq_flags, info->name, idev); - if (ret) + if (ret) { + info->uio_dev = NULL; goto err_request_irq; + } } - info->uio_dev = idev; return 0; err_request_irq: