mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-15 09:34:17 +00:00
usb: typec: unlock dp->lock on error exit path, and also zero ret if successful
One of the error handling paths forgets to unlock dp->lock on the error exit path leading to a potential lock-up. Also the return path for a successful call to the function configuration_store can return an uninitialized error return code if dp->alt->active is false, so ensure ret is zeroed on the successful exit path to avoid garbage being returned. Detected by CoverityScan, CID#1471597 ("Unitialized scalar variable") Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
11b71782c1
commit
98a1a0c7a3
@ -333,7 +333,7 @@ configuration_store(struct device *dev, struct device_attribute *attr,
|
|||||||
u32 conf;
|
u32 conf;
|
||||||
u32 cap;
|
u32 cap;
|
||||||
int con;
|
int con;
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
con = sysfs_match_string(configurations, buf);
|
con = sysfs_match_string(configurations, buf);
|
||||||
if (con < 0)
|
if (con < 0)
|
||||||
@ -349,8 +349,10 @@ configuration_store(struct device *dev, struct device_attribute *attr,
|
|||||||
cap = DP_CAP_CAPABILITY(dp->alt->vdo);
|
cap = DP_CAP_CAPABILITY(dp->alt->vdo);
|
||||||
|
|
||||||
if ((con == DP_CONF_DFP_D && !(cap & DP_CAP_DFP_D)) ||
|
if ((con == DP_CONF_DFP_D && !(cap & DP_CAP_DFP_D)) ||
|
||||||
(con == DP_CONF_UFP_D && !(cap & DP_CAP_UFP_D)))
|
(con == DP_CONF_UFP_D && !(cap & DP_CAP_UFP_D))) {
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto err_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
conf = dp->data.conf & ~DP_CONF_DUAL_D;
|
conf = dp->data.conf & ~DP_CONF_DUAL_D;
|
||||||
conf |= con;
|
conf |= con;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user