Skip to content

Commit f019f07

Browse files
Dan Carpentergregkh
authored andcommitted
uio: potential double frees if __uio_register_device() fails
The uio_unregister_device() function assumes that if "info->uio_dev" is non-NULL that means "info" is fully allocated. Setting info->uio_de has to be the last thing in the function. In the current code, if request_threaded_irq() fails then we return with info->uio_dev set to non-NULL but info is not fully allocated and it can lead to double frees. Fixes: beafc54 ("UIO: Add the User IO core code") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c01513b commit f019f07

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/uio/uio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,6 @@ int __uio_register_device(struct module *owner,
953953
if (ret)
954954
goto err_uio_dev_add_attributes;
955955

956-
info->uio_dev = idev;
957-
958956
if (info->irq && (info->irq != UIO_IRQ_CUSTOM)) {
959957
/*
960958
* Note that we deliberately don't use devm_request_irq
@@ -971,6 +969,7 @@ int __uio_register_device(struct module *owner,
971969
goto err_request_irq;
972970
}
973971

972+
info->uio_dev = idev;
974973
return 0;
975974

976975
err_request_irq:

0 commit comments

Comments
 (0)