[LTP] fanotify22.c: handle multiple asynchronous error events
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Apr 29 16:51:32 CEST 2026
Hi Wei,
On 2026-03-31, Wei Gao <wegao@suse.com> wrote:
> fanotify22.c: handle multiple asynchronous error events
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202602042124.87bd00e3-lkp@intel.com
> Signed-off-by: Wei Gao <wegao@suse.com>
This fixes a known sporadic failure; please add a Fixes: tag referencing
the LTP commit that introduced fanotify22.
> + for (metadata = (struct fanotify_event_metadata *)buf;
> + FAN_EVENT_OK(metadata, len);
> + metadata = FAN_EVENT_NEXT(metadata, len)) {
> +
> + event_num++;
> + struct fanotify_event_info_error *info = get_event_info_error(metadata);
Declaration after statement. Move `info` to the top of the for-loop block.
Same issue with `current_pos`, `ret`, and `m` inside the while loop in
do_test(). Kernel coding style requires declarations at the top of each block.
> + if (info->error != ex->error && (ex->error2 == 0 || info->error != ex->error2)) {
> + ...
> + continue;
> + }
> +
> + if (!first) {
> + first = metadata;
> + first_info = info;
> + }
Logic bug: `first` is set to the first valid event in buffer order, which
may be the error2 (ESHUTDOWN) event with null_fid. check_event() then
validates that event's FID against ex->fid (bad_file_fid) and fails.
Set `first` only when `info->error == ex->error` so the event with the
expected FID is always selected.
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list