git: hammer2: Fix a NULL deref in hammer2_chain_lastdrop()
Aaron LI
aly at crater.dragonflybsd.org
Tue Oct 13 04:50:40 PDT 2026
commit fde6d850ed48936eb946997085fd986d2bb3b434
Author: Aaron LI <aly at aaronly.me>
Date: Tue Oct 13 09:09:55 2026 +0800
hammer2: Fix a NULL deref in hammer2_chain_lastdrop()
That is the no-parent case, i.e., parent is NULL, so it was an error
to access 'parent->core.spin'. Simply remove the hammer2_spin_unex()
call to fix the bug.
This bug was caught by the GCC 12.5 warning:
```
In file included from include/machine/atomic.h:7,
from /usr/src/sys/sys/systm.h:49,
from /usr/src/sys/vfs/hammer2/hammer2_chain.c:57:
In function 'atomic_add_int',
inlined from 'spin_unlock_quick' at /usr/src/sys/sys/spinlock2.h:170:2,
inlined from 'spin_unlock' at /usr/src/sys/sys/spinlock2.h:183:2,
inlined from 'hammer2_chain_lastdrop' at /usr/src/sys/vfs/hammer2/hammer2_chain.c:654:4,
inlined from 'hammer2_chain_drop' at /usr/src/sys/vfs/hammer2/hammer2_chain.c:359:13,
inlined from 'hammer2_chain_drop' at /usr/src/sys/vfs/hammer2/hammer2_chain.c:346:1:
./cpu/atomic.h:91:9: warning: array subscript 0 is outside array bounds of 'int[0]' [-Warray-bounds]
91 | __asm __volatile(MPLOCKED OP \
| ^~~~~
./cpu/atomic.h:130:1: note: in expansion of macro 'ATOMIC_ASM'
130 | ATOMIC_ASM(add, int, "addl %1,%0", "iq", v)
| ^~~~~~~~~~
./cpu/atomic.h:91:9: warning: array subscript 0 is outside array bounds of 'int[0]' [-Warray-bounds]
91 | __asm __volatile(MPLOCKED OP \
| ^~~~~
./cpu/atomic.h:130:1: note: in expansion of macro 'ATOMIC_ASM'
130 | ATOMIC_ASM(add, int, "addl %1,%0", "iq", v)
| ^~~~~~~~~~
```
Summary of changes:
sys/vfs/hammer2/hammer2_chain.c | 1 -
1 file changed, 1 deletion(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/fde6d850ed48936eb946997085fd986d2bb3b434
--
DragonFly BSD source repository
More information about the Commits
mailing list