From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: accel/habanalabs: reject zero-element timestamp buffer allocation Date: Sat, 14 Feb 2026 07:24:29 +1000 Message-ID: In-Reply-To: <20260213173530.2963318-1-n7l8m4@u.northwestern.edu> References: <20260213173530.2963318-1-n7l8m4@u.northwestern.edu> <20260213173530.2963318-1-n7l8m4@u.northwestern.edu> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review The analysis checks out. The call chain is: `hl_mem_ioctl()` =E2=86=92 `allocate_timestamps_buffers()` =E2=86=92 `hl_mmap= _mem_buf_alloc()` =E2=86=92 `hl_ts_alloc_buf()` In `hl_ts_alloc_buf()`, the num_of_elements value is used in `vmalloc_user(nu= m_elements * sizeof(u64))`. With `num_of_elements=3D0`, the size is zero, whi= ch hits the `WARN_ON_ONCE` in the vmalloc internals. The value comes directly= from userspace via the ioctl `args->num_of_elements` with no intervening val= idation for zero. The fix itself: > ``` > - if (args->num_of_elements > TS_MAX_ELEMENTS_NUM) { > - dev_err(mmg->dev, "Num of elements exceeds Max allowed number (0x%x > 0x= %x)\n", > + if (args->num_of_elements > TS_MAX_ELEMENTS_NUM || > + args->num_of_elements =3D=3D 0) { > + dev_err(mmg->dev, "Invalid num of elements %u, valid range [1, 0x%x]\n", > args->num_of_elements, TS_MAX_ELEMENTS_NUM); > return -EINVAL; > } > ``` One minor style note: the condition could be written more naturally as `!args= ->num_of_elements || args->num_of_elements > TS_MAX_ELEMENTS_NUM` (checking t= he lower bound first, then the upper bound), which reads as a range check. Bu= t this is purely a readability preference =E2=80=94 the logic is correct eith= er way. The updated error message is a good improvement =E2=80=94 it now describes th= e valid range rather than only the upper-bound violation, which is more infor= mative when the zero case is hit. No bugs found. The patch is correct and ready to apply. --- Generated by Claude Code Patch Reviewer