Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6452ab11 authored by Jack Pham's avatar Jack Pham Committed by Gerrit - the friendly Code Review server
Browse files

usb: pd: fix off-by-one in rdo_h_show



When viewing rdo_h via sysfs, the request type is determined by
looking up the type from the PDO list, however the obj_pos field
is 1-based whereas the received_pdos is 0-based. This off-by-one
error can result in misinterpretation of the request object, e.g.
viewing a PPS request may show the fields for a Fixed request.

Change-Id: If5f25cdadb7838b8f846ca90b16f8b17539d1e37
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 9660be9b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3580,7 +3580,7 @@ static ssize_t rdo_h_show(struct device *dev, struct device_attribute *attr,
{
	struct usbpd *pd = dev_get_drvdata(dev);
	int pos = PD_RDO_OBJ_POS(pd->rdo);
	int type = PD_SRC_PDO_TYPE(pd->received_pdos[pos]);
	int type = PD_SRC_PDO_TYPE(pd->received_pdos[pos - 1]);
	int len;

	len = scnprintf(buf, PAGE_SIZE, "Request Data Object\n"