Message ID | 20250131013832.24805-1-jiashengjiangcool@gmail.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ice: Add check for devm_kzalloc() | expand |
On Fri, Jan 31, 2025 at 01:38:32AM +0000, Jiasheng Jiang wrote: > Add check for the return value of devm_kzalloc() to guarantee the success > of allocation. > > Fixes: 42c2eb6b1f43 ("ice: Implement devlink-rate API") > Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> > --- > drivers/net/ethernet/intel/ice/devlink/devlink.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c > index d116e2b10bce..dbdb83567364 100644 > --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c > +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c > @@ -981,6 +981,9 @@ static int ice_devlink_rate_node_new(struct devlink_rate *rate_node, void **priv > > /* preallocate memory for ice_sched_node */ > node = devm_kzalloc(ice_hw_to_dev(pi->hw), sizeof(*node), GFP_KERNEL); > + if (!node) > + return -ENOMEM; > + Thanks for fixing: Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > *priv = node; > > return 0; > -- > 2.25.1
diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index d116e2b10bce..dbdb83567364 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -981,6 +981,9 @@ static int ice_devlink_rate_node_new(struct devlink_rate *rate_node, void **priv /* preallocate memory for ice_sched_node */ node = devm_kzalloc(ice_hw_to_dev(pi->hw), sizeof(*node), GFP_KERNEL); + if (!node) + return -ENOMEM; + *priv = node; return 0;
Add check for the return value of devm_kzalloc() to guarantee the success of allocation. Fixes: 42c2eb6b1f43 ("ice: Implement devlink-rate API") Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> --- drivers/net/ethernet/intel/ice/devlink/devlink.c | 3 +++ 1 file changed, 3 insertions(+)