* [PATCH v3] ax25: use GFP_KERNEL in ax25_dev_device_up()
@ 2022-06-15 22:09 Peter Lafreniere
2022-06-16 11:19 ` Paolo Abeni
0 siblings, 1 reply; 2+ messages in thread
From: Peter Lafreniere @ 2022-06-15 22:09 UTC (permalink / raw)
To: linux-hams; +Cc: netdev, Peter Lafreniere, kernel test robot, Dan Carpenter
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: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peter Lafreniere <pjlafren@mtu.edu>
---
v2 -> v3:
- Rebased for clean application to net-next
v1 -> v2:
- Renamed patch from "ax25: use GFP_KERNEL over GFP_ATOMIC where possible"
(Is that okay?)
- Removed invalid changes to ax25_rt_add()
net/ax25/ax25_dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
index ab88b6ac5401..2093f94f6852 100644
--- a/net/ax25/ax25_dev.c
+++ b/net/ax25/ax25_dev.c
@@ -52,7 +52,7 @@ void ax25_dev_device_up(struct net_device *dev)
{
ax25_dev *ax25_dev;
- if ((ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_ATOMIC)) == NULL) {
+ if ((ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_KERNEL)) == NULL) {
printk(KERN_ERR "AX.25: ax25_dev_device_up - out of memory\n");
return;
}
@@ -60,7 +60,7 @@ void ax25_dev_device_up(struct net_device *dev)
refcount_set(&ax25_dev->refcount, 1);
dev->ax25_ptr = ax25_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->device_up = true;
base-commit: fbb89d02e33a8c8f522d75882f5f19c65b722b46
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ax25: use GFP_KERNEL in ax25_dev_device_up()
2022-06-15 22:09 [PATCH v3] ax25: use GFP_KERNEL in ax25_dev_device_up() Peter Lafreniere
@ 2022-06-16 11:19 ` Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2022-06-16 11:19 UTC (permalink / raw)
To: Peter Lafreniere, linux-hams; +Cc: netdev, kernel test robot, Dan Carpenter
Hello,
On Wed, 2022-06-15 at 18:09 -0400, Peter Lafreniere wrote:
> 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: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Peter Lafreniere <pjlafren@mtu.edu>
> ---
> v2 -> v3:
> - Rebased for clean application to net-next
>
> v1 -> v2:
> - Renamed patch from "ax25: use GFP_KERNEL over GFP_ATOMIC where possible"
> (Is that okay?)
> - Removed invalid changes to ax25_rt_add()
>
> net/ax25/ax25_dev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
> index ab88b6ac5401..2093f94f6852 100644
> --- a/net/ax25/ax25_dev.c
> +++ b/net/ax25/ax25_dev.c
> @@ -52,7 +52,7 @@ void ax25_dev_device_up(struct net_device *dev)
> {
> ax25_dev *ax25_dev;
>
> - if ((ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_ATOMIC)) == NULL) {
> + if ((ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_KERNEL)) == NULL) {
> printk(KERN_ERR "AX.25: ax25_dev_device_up - out of memory\n");
> return;
> }
Since you are touching this line, please move the assignment in a
separate statement:
ax25_dev = kzalloc(sizeof(*ax25_dev), GFP_KERNEL);
if (!ax25_dev) {
so that we get rid of this obsolete codying style.
Thanks!
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-16 11:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 22:09 [PATCH v3] ax25: use GFP_KERNEL in ax25_dev_device_up() Peter Lafreniere
2022-06-16 11:19 ` Paolo Abeni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.