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
This commit is contained in:
Warner Losh 2021-06-03 12:03:45 -06:00
parent ef65f7bdf2
commit ce0a9d7c12

View File

@ -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);
}