mirror of
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10.git
synced 2026-09-09 00:07:04 +08:00
i2c: core: fix reference leak in i2c_register_adapter()
JIRA: https://redhat.atlassian.net/browse/RHEL-222908
CVE: CVE-2026-64279
commit 3f8c4f5e9a57868fa107016c81165686d23325f2
Author: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Date: Wed Dec 11 12:08:03 2024 +0900
i2c: core: fix reference leak in i2c_register_adapter()
The reference count of the device incremented in device_initialize() is
not decremented when device_add() fails. Add a put_device() call before
returning from the function.
This bug was found by an experimental static analysis tool that I am
developing.
Fixes: 60f6859702 ("i2c: core: Setup i2c_adapter runtime-pm before calling device_add()")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Steve Best <sbest@redhat.com>
This commit is contained in:
@@ -1563,6 +1563,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
|
||||
res = device_add(&adap->dev);
|
||||
if (res) {
|
||||
pr_err("adapter '%s': can't register device (%d)\n", adap->name, res);
|
||||
put_device(&adap->dev);
|
||||
goto out_list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user