Re: [PATCH net] devlink: Add missing genlmsg_cancel() in devlink_nl_sb_port_pool_fill()

From: wanghai (M)
Date: Fri Nov 13 2020 - 07:20:39 EST



在 2020/11/13 1:51, Jakub Kicinski 写道:
On Wed, 11 Nov 2020 21:58:53 +0800 Wang Hai wrote:
If sb_occ_port_pool_get() failed in devlink_nl_sb_port_pool_fill(),
msg should be canceled by genlmsg_cancel().
+++ b/net/core/devlink.c
@@ -1447,8 +1447,10 @@ static int devlink_nl_sb_port_pool_fill(struct sk_buff *msg,
[...]
return err;
I guess the driver would have to return -EMSGSIZE for this to matter,
which is quite unlikely but we should indeed fix.

Still, returning in the middle of the function with an epilogue is what
got use here in the first place, so please use a goto. E.g. like this:

[...]
static int devlink_nl_cmd_sb_port_pool_get_doit(struct sk_buff *skb,

.

Thanks for your review,  I just sent v2

[PATCH v2 net] devlink: Add missing genlmsg_cancel() in devlink_nl_sb_port_pool_fill()