Commit f0623340 authored by Peter Lafreniere's avatar Peter Lafreniere Committed by Jakub Kicinski

ax25: use GFP_KERNEL in ax25_dev_device_up()

ax25_dev_device_up() is only called during device setup, which is
done in user context. In addition, ax25_dev_device_up()
unconditionally calls ax25_register_dev_sysctl(), which already
allocates with GFP_KERNEL.

Since it is allowed to sleep in this function, here we change
ax25_dev_device_up() to use GFP_KERNEL to reduce unnecessary
out-of-memory errors.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarPeter Lafreniere <pjlafren@mtu.edu>
Link: https://lore.kernel.org/r/20220616152333.9812-1-pjlafren@mtu.eduSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f691b4d8
...@@ -52,7 +52,8 @@ void ax25_dev_device_up(struct net_device *dev) ...@@ -52,7 +52,8 @@ void ax25_dev_device_up(struct net_device *dev)
{ {
ax25_dev *ax25_dev; ax25_dev *ax25_dev;
if ((ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_ATOMIC)) == NULL) { ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_KERNEL);
if (!ax25_dev) {
printk(KERN_ERR "AX.25: ax25_dev_device_up - out of memory\n"); printk(KERN_ERR "AX.25: ax25_dev_device_up - out of memory\n");
return; return;
} }
...@@ -60,7 +61,7 @@ void ax25_dev_device_up(struct net_device *dev) ...@@ -60,7 +61,7 @@ void ax25_dev_device_up(struct net_device *dev)
refcount_set(&ax25_dev->refcount, 1); refcount_set(&ax25_dev->refcount, 1);
dev->ax25_ptr = ax25_dev; dev->ax25_ptr = ax25_dev;
ax25_dev->dev = dev; ax25_dev->dev = dev;
netdev_hold(dev, &ax25_dev->dev_tracker, GFP_ATOMIC); netdev_hold(dev, &ax25_dev->dev_tracker, GFP_KERNEL);
ax25_dev->forward = NULL; ax25_dev->forward = NULL;
ax25_dev->device_up = true; ax25_dev->device_up = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment