Commit bfe2c99c authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: hd: fix cport-count check

Fix off-by-one error when checking the number of cports a host-device
supports.

The CPORT_ID_MAX is the largest valid cport id so the maximum number of
cports a host-device can use is CPORT_ID_MAX + 1.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 39f36c8f
...@@ -49,7 +49,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, ...@@ -49,7 +49,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (num_cports == 0 || num_cports > CPORT_ID_MAX) { if (num_cports == 0 || num_cports > CPORT_ID_MAX + 1) {
dev_err(parent, "Invalid number of CPorts: %zu\n", num_cports); dev_err(parent, "Invalid number of CPorts: %zu\n", num_cports);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment