diff options
author | Nicolas Boichat <drinkcat@google.com> | 2016-12-08 10:45:04 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-08 22:47:02 -0800 |
commit | 9d7d189450182a9da68b922a737c89bccbd81925 (patch) | |
tree | c2b7ac7b23cd12dedb92eed0f38caea4e27bb28c /common | |
parent | 0d5562fa73d59d00c1ebf3bfc6a0640f7c3f8f03 (diff) | |
download | chrome-ec-9d7d189450182a9da68b922a737c89bccbd81925.tar.gz |
usb_pd_protocol: tcpm_get_message: Check return value
We currently rely on *head == 0 as error condition, which is
fragile and inconsistent across TCPCs implementations.
Instead, let's return a proper return value on all implementations.
BRANCH=none
BUG=chrome-os-partner:60575
TEST=elm FW as of 65fb80d (later version include a fix that would
hide this issue), cherry-pick this patch, connect j5create
adapter, then HDMI, then power => no crash
Change-Id: If7235e0491e9f80fdd50ce2605477ee518f8e1aa
Reviewed-on: https://chromium-review.googlesource.com/417443
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_pd_protocol.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 3ea1dbf723..e50bc7f734 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1698,8 +1698,7 @@ void pd_task(void) /* process any potential incoming message */ incoming_packet = evt & PD_EVENT_RX; if (incoming_packet) { - tcpm_get_message(port, payload, &head); - if (head > 0) + if (!tcpm_get_message(port, payload, &head)) handle_request(port, head, payload); } /* if nothing to do, verify the state of the world in 500ms */ |