Skip to content

Commit a888bbd

Browse files
committed
ethtool: tsconfig: fix reply error handling
A couple of trivial bugs in error handling in tsconfig_send_reply(). If we failed to allocate rskb we need to set the error. If we did allocate it but failed to send it - we need to remember to free it. Fixes: 6e9e2ee ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config") Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Reviewed-by: Kory Maincent <kory.maincent@bootlin.com> Link: https://patch.msgid.link/20260526153533.2779187-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7281b09 commit a888bbd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

net/ethtool/tsconfig.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,21 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info)
224224
reply_len = ret + ethnl_reply_header_size();
225225
rskb = ethnl_reply_init(reply_len, dev, ETHTOOL_MSG_TSCONFIG_SET_REPLY,
226226
ETHTOOL_A_TSCONFIG_HEADER, info, &reply_payload);
227-
if (!rskb)
227+
if (!rskb) {
228+
ret = -ENOMEM;
228229
goto err_cleanup;
230+
}
229231

230232
ret = tsconfig_fill_reply(rskb, &req_info->base, &reply_data->base);
231233
if (ret < 0)
232-
goto err_cleanup;
234+
goto err_free_msg;
233235

234236
genlmsg_end(rskb, reply_payload);
235237
ret = genlmsg_reply(rskb, info);
238+
rskb = NULL;
236239

240+
err_free_msg:
241+
nlmsg_free(rskb);
237242
err_cleanup:
238243
kfree(reply_data);
239244
kfree(req_info);

0 commit comments

Comments
 (0)