As we propagate extended ack reporting throughout various paths in the kernel it may happen that the same function is called with the extended ack parameter passed as NULL. Make the NL_SET_ERR_MSG() macro simply print the message to the logs if that happens.
Signed-off-by: Jakub Kicinski <jakub.kicin...@netronome.com> --- include/linux/netlink.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 8d2a8924705c..b59cfbf2e2c7 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -86,10 +86,14 @@ struct netlink_ext_ack { * Currently string formatting is not supported (due * to the lack of an output buffer.) */ -#define NL_SET_ERR_MSG(extack, msg) do { \ - static const char _msg[] = (msg); \ - \ - (extack)->_msg = _msg; \ +#define NL_SET_ERR_MSG(extack, msg) do { \ + struct netlink_ext_ack *_extack = (extack); \ + static const char _msg[] = (msg); \ + \ + if (_extack) \ + _extack->_msg = _msg; \ + else \ + pr_info("%s\n", _msg); \ } while (0) extern void netlink_kernel_release(struct sock *sk); -- 2.11.0