Skip to contentSkip to conversation

staging: greybus: hid: Remove print following unsuccessful kmalloc

PATCH In review Sanjana Sanikommu 2 participants 4 messages Mar 31, 2019 – Apr 1, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: hid: Remove print following unsuccessful kmalloc

Challenge suggested by Coccinelle
Remove print statement following unsuccessful kmalloc when there is not enough memory. Kmalloc and variants normally produce a backtrace in such a case. Hence, a print statement is not necessary.

Found using the following Coccinelle semantic patch:
@@
identifier i,print;
constant char [] c;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\| devm_ioremap\|usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\| kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...));
(
if (i == NULL)
{
-print(...,c,...);
...when any
}
|
if (!i)
{
-print(...,c,...);
...when any
}
)

---
 drivers/staging/greybus/hid.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/greybus/hid.c +0 -1
index 0b72e1b9d325..8ab810bf5716 100644
@@ -292,7 +292,6 @@ static int gb_hid_parse(struct hid_device *hid)
 
 	rdesc = kzalloc(rsize, GFP_KERNEL);
 	if (!rdesc) {
-		dbg_hid("couldn't allocate rdesc memory\n");
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 20 lines · Sanjana Sanikommu

Challenge suggested by Coccinelle
Remove print statement following unsuccessful kmalloc when there is not enough memory. Kmalloc and variants normally produce a backtrace in such a case. Hence, a print statement is not necessary.

Found using the following Coccinelle semantic patch:
@@
identifier i,print;
constant char [] c;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\| devm_ioremap\|usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\| kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...));
(
if (i == NULL)
{
-print(...,c,...);
...when any

Quoted 8 lines

}
|
if (!i)
{
-print(...,c,...);
...when any
}
)

No need to change, but with the pattern i == NULL, Coccinelle will match !i too.

julia

Quoted 28 lines
---
 drivers/staging/greybus/hid.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/greybus/hid.c +0 -2
index 0b72e1b9d325..8ab810bf5716 100644
@@ -292,7 +292,6 @@ static int gb_hid_parse(struct hid_device *hid)
 
 	rdesc = kzalloc(rsize, GFP_KERNEL);
 	if (!rdesc) {
-		dbg_hid("couldn't allocate rdesc memory\n");
 		return -ENOMEM;
 	}
 
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190331160402.27940-1-sanjana99reddy99%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 27 lines · On Sun, 31 Mar 2019, 22:03 Julia Lawall, <[email protected]> wrote:
Quoted 23 lines · Sanjana Sanikommu

Challenge suggested by Coccinelle
Remove print statement following unsuccessful kmalloc when there is not enough memory. Kmalloc and variants normally produce a backtrace in such a case. Hence, a print statement is not necessary.

Found using the following Coccinelle semantic patch:
@@
identifier i,print;
constant char [] c;
@@

i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\| devm_ioremap\|usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\| kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...));
(
if (i == NULL)
{
-print(...,c,...);
...when any
}
|
if (!i)

Quoted 9 lines
Quoted 5 lines

{
-print(...,c,...);
...when any
}
)

No need to change, but with the pattern i == NULL, Coccinelle will match !i too.

Shall I update the semantic patch ? Plz let me know...

Thank you
Sanjana

Quoted 48 lines

julia

Review

Quoted 7 lines
---
 drivers/staging/greybus/hid.c | 1 -
 1 file changed, 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/greybus/hid.c

Quoted 14 lines

index 0b72e1b9d325..8ab810bf5716 100644

drivers/staging/greybus/hid.c +0 -2
@@ -292,7 +292,6 @@ static int gb_hid_parse(struct hid_device *hid)
 
      rdesc = kzalloc(rsize, GFP_KERNEL);
      if (!rdesc) {
-             dbg_hid("couldn't allocate rdesc memory\n");
              return -ENOMEM;
      }
 
--

2.17.1

Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20190331160402.27940-1-sanjana99reddy99%40gmail.com
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1903311833100.2578%40hadrien
.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 43 lines · Sanjana Sanikommu

On Sun, 31 Mar 2019, 22:03 Julia Lawall, <[email protected]> wrote:

      On Sun, 31 Mar 2019, Sanjana Sanikommu wrote:

      > Challenge suggested by Coccinelle
      > Remove print statement following unsuccessful kmalloc when
      there
      > is not enough memory. Kmalloc and variants normally produce a
      > backtrace in such a case. Hence, a print statement is not
      necessary.
      >
      > Found using the following Coccinelle semantic patch:
      > @@
      > identifier i,print;
      > constant char [] c;
      > @@
      >
      > i = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|
      > devm_ioremap\|usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\|
      > kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|
      >    kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...));
      > (
      > if (i == NULL)
      > {
      > -print(...,c,...);
      > ...when any
      > }
      > |
      > if (!i)
      > {
      > -print(...,c,...);
      > ...when any
      > }
      > )

      No need to change, but with the pattern i == NULL, Coccinelle
      will match
      !i too.
Quoted 1 line

   Shall I update the semantic patch ? Plz let me know...

There is no need to change it.

julia

Quoted 65 lines

 Thank you
Sanjana

      julia

      >
      > Signed-off-by: Sanjana Sanikommu <[email protected]>
      > ---
      >  drivers/staging/greybus/hid.c | 1 -
      >  1 file changed, 1 deletion(-)
      >
      > diff --git a/drivers/staging/greybus/hid.c
      b/drivers/staging/greybus/hid.c
      > index 0b72e1b9d325..8ab810bf5716 100644
      > --- a/drivers/staging/greybus/hid.c
      > +++ b/drivers/staging/greybus/hid.c
      > @@ -292,7 +292,6 @@ static int gb_hid_parse(struct hid_device
      *hid)
      >
      >       rdesc = kzalloc(rsize, GFP_KERNEL);
      >       if (!rdesc) {
      > -             dbg_hid("couldn't allocate rdesc memory\n");
      >               return -ENOMEM;
      >       }
      >
      > --
      > 2.17.1
      >
      > --
      > You received this message because you are subscribed to the
      Google Groups "outreachy-kernel" group.
      > To unsubscribe from this group and stop receiving emails from
      it, send an email to
      [email protected].
      > To post to this group, send email to
      [email protected].
      > To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20190331160402.27940-1-s
      anjana99reddy99%40gmail.com.
      > For more options, visit https://groups.google.com/d/optout.
      >

      --
      You received this message because you are subscribed to the
      Google Groups "outreachy-kernel" group.
      To unsubscribe from this group and stop receiving emails from
      it, send an email to
      [email protected].
      To post to this group, send email to
      [email protected].
      To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.19033118
      33100.2578%40hadrien.
      For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAO-bXGC%3DKEM-sA3Z7mL70 xDLPPUfoQ78AxyUbu-5ggBeyA5OmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.