mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
mfd: Fix twl-core oops while calling twl_i2c_* for unbound driver
commit 8653be1afd upstream.
Check inuse variable before trying to access twl_map to prevent
dereferencing of uninitialized variable.
Signed-off-by: Ilya Yanok <yanok@emcraft.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b05727c7f8
commit
20e725bc08
@@ -362,13 +362,13 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
|
||||
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
|
||||
return -EPERM;
|
||||
}
|
||||
if (unlikely(!inuse)) {
|
||||
pr_err("%s: not initialized\n", DRIVER_NAME);
|
||||
return -EPERM;
|
||||
}
|
||||
sid = twl_map[mod_no].sid;
|
||||
twl = &twl_modules[sid];
|
||||
|
||||
if (unlikely(!inuse)) {
|
||||
pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
|
||||
return -EPERM;
|
||||
}
|
||||
mutex_lock(&twl->xfer_lock);
|
||||
/*
|
||||
* [MSG1]: fill the register address data
|
||||
@@ -419,13 +419,13 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
|
||||
pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
|
||||
return -EPERM;
|
||||
}
|
||||
if (unlikely(!inuse)) {
|
||||
pr_err("%s: not initialized\n", DRIVER_NAME);
|
||||
return -EPERM;
|
||||
}
|
||||
sid = twl_map[mod_no].sid;
|
||||
twl = &twl_modules[sid];
|
||||
|
||||
if (unlikely(!inuse)) {
|
||||
pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
|
||||
return -EPERM;
|
||||
}
|
||||
mutex_lock(&twl->xfer_lock);
|
||||
/* [MSG1] fill the register address data */
|
||||
msg = &twl->xfer_msg[0];
|
||||
|
||||
Reference in New Issue
Block a user