Re: [PATCH 5/6] Input: mms114 - replace BUG() and fix alignment
From: Bryam Vargas <hidden>
Date: 2026-06-16 07:21:42
Also in:
lkml
Hi Dmitry, Replacing BUG() with WARN_ON() + return is the right call, and the rest of the patch is fine. One nit on the changelog though: this guard isn't reachable from userspace. reg and len are always driver-internal constants -- there is no sysfs/debugfs/ ioctl that lets userspace pick a register, every __mms114_read_reg() call site passes a fixed reg >= MMS114_INFORMATION (0x10), and the single MMS114_MODE_CONTROL read is short-circuited by the cache in mms114_read_reg() before it ever reaches __mms114_read_reg(). So the condition only fires if a *future in-kernel caller* requests a read that spans the write-only MODE_CONTROL register -- a driver- internal invariant, not a userspace-triggered one. Worth tightening the wording, since that distinction is exactly what justifies WARN_ON() here: a genuinely userspace-reachable WARN_ON() would itself be a problem (log spam / panic_on_warn). Maybe something like: "Avoid taking the machine down with BUG() if a caller ever requests a read spanning the write-only MODE_CONTROL register; warn and return -EINVAL so the driver can recover." The code is good either way. Thanks, Bryam