Date: Thu, 3 Jun 2021 18:04:18 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: ce0a9d7c126f - main - axgbe: Don't dereference NULL pointers Message-ID: <202106031804.153I4IUv089170@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ce0a9d7c126fd712d3e3801323e9c8fb06269d64 commit ce0a9d7c126fd712d3e3801323e9c8fb06269d64 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2021-06-03 18:03:45 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-06-03 18:03:45 +0000 axgbe: Don't dereference NULL pointers if (sb == NULL) { ... sb->s_error } is going to be a bad time. Return ENOMEM when we cannot allocate an sbuf for the sysctl rather than dereferencing the NULL pointer just returned. Reviewed by: manu@, allanjude@ Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30373 --- sys/dev/axgbe/xgbe-sysctl.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sys/dev/axgbe/xgbe-sysctl.c b/sys/dev/axgbe/xgbe-sysctl.c index f7998b943b16..4f1e25e39ae2 100644 --- a/sys/dev/axgbe/xgbe-sysctl.c +++ b/sys/dev/axgbe/xgbe-sysctl.c @@ -515,7 +515,7 @@ sysctl_xgmac_reg_addr_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -551,7 +551,7 @@ sysctl_get_drv_info_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -583,7 +583,7 @@ sysctl_get_link_info_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -639,7 +639,7 @@ sysctl_coalesce_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } sys_op->rx_coalesce_usecs = pdata->rx_usecs; @@ -770,7 +770,7 @@ sysctl_pauseparam_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } sys_op->autoneg = pdata->phy.pause_autoneg; @@ -868,7 +868,7 @@ sysctl_link_ksettings_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } sys_op->autoneg = pdata->phy.autoneg; @@ -993,7 +993,7 @@ sysctl_ringparam_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } sys_op->rx_max_pending = XGBE_RX_DESC_CNT_MAX; @@ -1096,7 +1096,7 @@ sysctl_channels_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count); @@ -1174,7 +1174,7 @@ sysctl_mac_stats_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1220,7 +1220,7 @@ sysctl_xgmac_reg_value_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1256,7 +1256,7 @@ sysctl_xpcs_mmd_reg_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1293,7 +1293,7 @@ sysctl_xpcs_reg_addr_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1330,7 +1330,7 @@ sysctl_xpcs_reg_value_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1368,7 +1368,7 @@ sysctl_xprop_reg_addr_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1405,7 +1405,7 @@ sysctl_xprop_reg_value_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1441,7 +1441,7 @@ sysctl_xi2c_reg_addr_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1478,7 +1478,7 @@ sysctl_xi2c_reg_value_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1514,7 +1514,7 @@ sysctl_an_cdr_wr_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); } @@ -1555,7 +1555,7 @@ sysctl_an_cdr_track_early_handler(SYSCTL_HANDLER_ARGS) if (req->newptr == NULL) { sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); if (sb == NULL) { - rc = sb->s_error; + rc = ENOMEM; return (rc); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106031804.153I4IUv089170>