greybus: hd: fix cport-count check
authorJohan Hovold <johan@hovoldconsulting.com>
Sun, 22 Nov 2015 09:12:58 +0000 (10:12 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 24 Nov 2015 03:23:27 +0000 (19:23 -0800)
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: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/hd.c

index b22d5470508a4d48c69fe7c0ec412cb473262acb..3446fec358958b41c01f70c292f5b6e25883ec8d 100644 (file)
@@ -49,7 +49,7 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver,
                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);
                return ERR_PTR(-EINVAL);
        }