mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
opticsmon: Handle error return of ethtool_nl_connect()
Don't just ignore the return of ethtool_nl_connect(). This would also otherwise lead to invalid socket accesses later. Also make ethtool_nl_connect() return negative error values instead of EXIT_FAILURE. Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
6847b6a8cf
commit
3696d6bd08
@@ -56,13 +56,13 @@ int ethtool_nl_connect(struct ethtool_nl_ctx *ctx)
|
||||
sk = nl_socket_alloc();
|
||||
if (!sk) {
|
||||
nl_perror(NLE_NOMEM, "alloc");
|
||||
return EXIT_FAILURE;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
rc = genl_connect(sk);
|
||||
if (rc) {
|
||||
nl_perror(rc, "connect");
|
||||
rc = EXIT_FAILURE;
|
||||
rc = -EIO;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ int ethtool_nl_connect(struct ethtool_nl_ctx *ctx)
|
||||
fprintf(stderr, "Ethtool netlink family not found\n");
|
||||
else
|
||||
nl_perror(ethtool_id, "ctrl resolve");
|
||||
rc = EXIT_FAILURE;
|
||||
rc = -EIO;
|
||||
goto err_close;
|
||||
}
|
||||
ctx->sk = sk;
|
||||
|
||||
@@ -398,7 +398,9 @@ int main(int argc, char **argv)
|
||||
int ret;
|
||||
|
||||
parse_cmdline(argc, argv, &ctx.opts);
|
||||
ethtool_nl_connect(&ctx.ethtool_ctx);
|
||||
ret = ethtool_nl_connect(&ctx.ethtool_ctx);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (ctx.opts.monitor)
|
||||
ret = monitor_mode(&ctx);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user