Testing a kernel error path that never fires: A/B a module with one-shot fault injection

Field note

Start from the source of the kernel you're running, and diff it against your distro's tag. Build each variant out of tree:

makefile
obj-m := btmtk.o
bash
make -C /usr/lib/modules/$(uname -r)/build M=$PWD W=1 modules

Add the same hook to both variants. xchg makes it fire once, so the next setup is clean:

c
static int inject_errno;
module_param(inject_errno, int, 0600);

err = xchg(&inject_errno, 0);
if (err > 0 && err <= MAX_ERRNO)
	skb = ERR_PTR(-err);
else
	skb = /* the real call */;

Measure what the patch claims and nothing more. This patch claimed the ISO URB is stopped on failure, so both variants logged usb_anchor_empty() at the return point: 0 before the patch, 1 after. The setup completed in both, and hci0 stayed up.

Load each variant with insmod btmtk.ko inject_errno=12, read the log, and restore the stock module from a trap so a failed run can't leave the test build in place.

srcversion will differ from the stock module even when the source is identical, because out-of-tree builds hash differently. Use it to tell which .ko is loaded, and use the source diff and vermagic to prove what you built.