Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: Iterate pds array when showing the pd list

The pointers of each usb_power_delivery handles are stored in "pds"
array returned from the pd_get ops but not in the adjacent memory
calculated from "pd". Get the handles from "pds" array directly instead
of deriving them from "pd".

Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")
Cc: stable@vger.kernel.org
Signed-off-by: Kyle Tso <kyletso@google.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230623151036.3955013-3-kyletso@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kyle Tso and committed by
Greg Kroah-Hartman
4b642dc9 b33ebb24

+5 -6
+5 -6
drivers/usb/typec/class.c
··· 1277 1277 { 1278 1278 struct typec_port *port = to_typec_port(dev); 1279 1279 struct usb_power_delivery **pds; 1280 - struct usb_power_delivery *pd; 1281 - int ret = 0; 1280 + int i, ret = 0; 1282 1281 1283 1282 if (!port->ops || !port->ops->pd_get) 1284 1283 return -EOPNOTSUPP; ··· 1286 1287 if (!pds) 1287 1288 return 0; 1288 1289 1289 - for (pd = pds[0]; pd; pd++) { 1290 - if (pd == port->pd) 1291 - ret += sysfs_emit(buf + ret, "[%s] ", dev_name(&pd->dev)); 1290 + for (i = 0; pds[i]; i++) { 1291 + if (pds[i] == port->pd) 1292 + ret += sysfs_emit(buf + ret, "[%s] ", dev_name(&pds[i]->dev)); 1292 1293 else 1293 - ret += sysfs_emit(buf + ret, "%s ", dev_name(&pd->dev)); 1294 + ret += sysfs_emit(buf + ret, "%s ", dev_name(&pds[i]->dev)); 1294 1295 } 1295 1296 1296 1297 buf[ret - 1] = '\n';