Skip to contentSkip to conversation

kzalloc params swapped in pm_qos_power_open

PATCH Applied Dr. David Alan Gilbert 3 participants 3 messages Aug 22, 2010 – Aug 24, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kzalloc params swapped in pm_qos_power_open

Hi,
I was playing with sparse and it looks like it spotted that
the kzalloc in pm_qos_power_open in the current Linus's git tree seems to have its parameters swapped. I've got a patch below, I've only build tested it.

---
**BUILD TESTED ONLY** (against current git)

kernel/pm_qos_params.c +1 -1
index 996a4de..71dcc21 100644
@@ -348,7 +348,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
 
        pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
        if (pm_qos_class >= 0) {
-               struct pm_qos_request_list *req = kzalloc(GFP_KERNEL, sizeof(*req));
+               struct pm_qos_request_list *req = kzalloc(sizeof(*req), GFP_KERNEL);
                if (!req)
                        return -ENOMEM;
 
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
Acked-by mark gross on v1 1/1
#1 lore raw

Your right. :(

Its working by luck, GFP_KERNEL (= 0x10|0x40|0x80 = 0xD0 = 208 ) is not too big and not too small.

--mark

Quoted 39 lines

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:[email protected]]
Sent: Sunday, August 22, 2010 7:36 AM
To: [email protected]
Cc: [email protected]; Gross, Mark
Subject: [PATCH] kzalloc params swapped in pm_qos_power_open

Hi,
I was playing with sparse and it looks like it spotted that
the kzalloc in pm_qos_power_open in the current Linus's git tree seems to have its parameters swapped. I've got a patch below, I've only build tested it.

---
**BUILD TESTED ONLY** (against current git)

kernel/pm_qos_params.c +1 -1
index 996a4de..71dcc21 100644
@@ -348,7 +348,7 @@ static int pm_qos_power_open(struct inode *inode,
 struct file *filp)
 
       pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
       if (pm_qos_class >= 0) {
-               struct pm_qos_request_list *req = kzalloc(GFP_KERNEL,
 sizeof(*req));
+               struct pm_qos_request_list *req = kzalloc(sizeof(*req),
 GFP_KERNEL);
               if (!req)
                       return -ENOMEM;

--
-----Open up your eyes, open up your mind, open up your code -------

/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\ gro.gilbert @ treblig.org |                               | In Hex /

\ _________________________|_____ http://www.treblig.org |_______/

#2 lore raw
Quoted 5 lines · Mark

Your right. :(

Its working by luck, GFP_KERNEL (= 0x10|0x40|0x80 = 0xD0 = 208 ) is not too big and not too small.

Applied to suspend-2.6/pm-fixes, I'll ask Linus to pull it after a day or two in linux-next.

Thanks,
Rafael

Quoted 41 lines
Quoted 39 lines

-----Original Message-----
From: Dr. David Alan Gilbert [mailto:[email protected]]
Sent: Sunday, August 22, 2010 7:36 AM
To: [email protected]
Cc: [email protected]; Gross, Mark
Subject: [PATCH] kzalloc params swapped in pm_qos_power_open

Hi,
I was playing with sparse and it looks like it spotted that
the kzalloc in pm_qos_power_open in the current Linus's git tree seems to have its parameters swapped. I've got a patch below, I've only build tested it.

---
**BUILD TESTED ONLY** (against current git)

kernel/pm_qos_params.c +1 -1
index 996a4de..71dcc21 100644
@@ -348,7 +348,7 @@ static int pm_qos_power_open(struct inode *inode,
 struct file *filp)
 
       pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
       if (pm_qos_class >= 0) {
-               struct pm_qos_request_list *req = kzalloc(GFP_KERNEL,
 sizeof(*req));
+               struct pm_qos_request_list *req = kzalloc(sizeof(*req),
 GFP_KERNEL);
               if (!req)
                       return -ENOMEM;

--
-----Open up your eyes, open up your mind, open up your code -------

/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\ gro.gilbert @ treblig.org |                               | In Hex /

\ _________________________|_____ http://www.treblig.org |_______/