From: Johan Hovold Date: Sun, 22 Nov 2015 09:12:58 +0000 (+0100) Subject: greybus: hd: fix cport-count check X-Git-Tag: v4.14-rc1~2366^2~378^2~21^2~1021 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bfe2c99c1cd346b06a7d34274b9b826d40ab40a1;p=platform%2Fkernel%2Flinux-rpi.git 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: Johan Hovold Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c index b22d547..3446fec 100644 --- a/drivers/staging/greybus/hd.c +++ b/drivers/staging/greybus/hd.c @@ -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); }