mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
staging: comedi: Fix comedi_device refcnt leak in comedi_open
comedi_open() invokes comedi_dev_get_from_minor(), which returns a
reference of the COMEDI device to "dev" with increased refcount.
When comedi_open() returns, "dev" becomes invalid, so the refcount
should be decreased to keep refcount balanced.
The reference counting issue happens in one exception handling path of
comedi_open(). When "cfp" allocation is failed, the refcnt increased by
comedi_dev_get_from_minor() is not decreased, causing a refcnt leak.
Fix this issue by calling comedi_dev_put() on this error path when "cfp"
allocation is failed.
Fixes: 20f083c075
("staging: comedi: prepare support for per-file read and write subdevices")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/1587361459-83622-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0b59f10b1d
commit
332e0e17ad
1 changed files with 3 additions and 1 deletions
|
@ -2725,8 +2725,10 @@ static int comedi_open(struct inode *inode, struct file *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfp = kzalloc(sizeof(*cfp), GFP_KERNEL);
|
cfp = kzalloc(sizeof(*cfp), GFP_KERNEL);
|
||||||
if (!cfp)
|
if (!cfp) {
|
||||||
|
comedi_dev_put(dev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
cfp->dev = dev;
|
cfp->dev = dev;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue