OSDN Git Service

uio: Fix an Oops on load
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 26 Oct 2018 07:19:51 +0000 (10:19 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Nov 2018 15:13:09 +0000 (16:13 +0100)
commit8600660ce149b32961d0f298eb6cd1c22a161fb1
tree4d50299932c2d6fa0ae54de46f682c11f2c9b0cd
parenta0d5f816c574fe5faaba7c19f4a3b5b11aca8c63
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 <Mathias.Thore@infinera.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Tested-by: Mathias Thore <Mathias.Thore@infinera.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/uio/uio.c