diff options
author | Tzung-Bi Shih <tzungbi@kernel.org> | 2022-06-09 08:49:45 +0000 |
---|---|---|
committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2022-06-10 02:31:43 +0000 |
commit | 878c36f6caa45d6a6234465fb16da07fc639f51d (patch) | |
tree | c118f5013b418a4e73f354f3aea680dccd0c6186 /drivers/platform/chrome | |
parent | 3e97581ed9a24657cbfabaab215c9a646d94b351 (diff) | |
download | lwn-878c36f6caa45d6a6234465fb16da07fc639f51d.tar.gz lwn-878c36f6caa45d6a6234465fb16da07fc639f51d.zip |
platform/chrome: cros_ec_proto: handle empty payload in getting proto info
cros_ec_get_proto_info() expects to receive
sizeof(struct ec_response_get_protocol_info) from send_command(). The
payload is valid only if the return value is positive.
Return -EPROTO if send_command() returns 0 in cros_ec_get_proto_info().
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220609084957.3684698-10-tzungbi@kernel.org
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r-- | drivers/platform/chrome/cros_ec_proto.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c index 1009b8ee0f86..a34ef2b796b0 100644 --- a/drivers/platform/chrome/cros_ec_proto.c +++ b/drivers/platform/chrome/cros_ec_proto.c @@ -314,6 +314,11 @@ static int cros_ec_get_proto_info(struct cros_ec_device *ec_dev, int devidx) goto exit; } + if (ret == 0) { + ret = -EPROTO; + goto exit; + } + info = (struct ec_response_get_protocol_info *)msg->data; switch (devidx) { |