From: Dan Carpenter Date: Fri, 6 May 2022 14:53:52 +0000 (+0300) Subject: hte: Fix off by one in hte_push_ts_ns() X-Git-Tag: v5.19-rc1~16^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e30b64a3ab9b9640e25b2ee6d7a9d70c1efd3b67;p=thirdparty%2Fkernel%2Flinux.git hte: Fix off by one in hte_push_ts_ns() The &chip->gdev->ei[] array has chip->nlines elements so this > comparison needs to be >= to prevent an out of bounds access. The gdev->ei[] array is allocated in hte_register_chip(). Fixes: 31ab09b42188 ("drivers: Add hardware timestamp engine (HTE) subsystem") Signed-off-by: Dan Carpenter Reviewed-by: Dipen Patel Acked-by: Dipen Patel Signed-off-by: Thierry Reding --- diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c index 891b98ad609ee..a14c5bf290ff2 100644 --- a/drivers/hte/hte.c +++ b/drivers/hte/hte.c @@ -811,7 +811,7 @@ int hte_push_ts_ns(const struct hte_chip *chip, u32 xlated_id, if (!chip || !data || !chip->gdev) return -EINVAL; - if (xlated_id > chip->nlines) + if (xlated_id >= chip->nlines) return -EINVAL; ei = &chip->gdev->ei[xlated_id];