Commit a888bbd4 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

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: 6e9e2eed ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")
Reviewed-by: default avatarVadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: default avatarKory Maincent <kory.maincent@bootlin.com>
Link: https://patch.msgid.link/20260526153533.2779187-3-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7281b096
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -224,16 +224,21 @@ static int tsconfig_send_reply(struct net_device *dev, struct genl_info *info)
	reply_len = ret + ethnl_reply_header_size();
	rskb = ethnl_reply_init(reply_len, dev, ETHTOOL_MSG_TSCONFIG_SET_REPLY,
				ETHTOOL_A_TSCONFIG_HEADER, info, &reply_payload);
	if (!rskb)
	if (!rskb) {
		ret = -ENOMEM;
		goto err_cleanup;
	}

	ret = tsconfig_fill_reply(rskb, &req_info->base, &reply_data->base);
	if (ret < 0)
		goto err_cleanup;
		goto err_free_msg;

	genlmsg_end(rskb, reply_payload);
	ret = genlmsg_reply(rskb, info);
	rskb = NULL;

err_free_msg:
	nlmsg_free(rskb);
err_cleanup:
	kfree(reply_data);
	kfree(req_info);