PCMCIA-CIS: Adjustments for six function implementations
Subsystems (2)
cover PCMCIA-CIS: Adjustments for six function implementations
From: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 22:42:10 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
cistpl: Delete error messages for a failed memory allocation
in three functions
cis: Delete an error message for a failed memory allocation
in two functions
cis: Improve a size determination in pcmcia_loop_config()
drivers/pcmcia/cistpl.c | 12 ++++-------- drivers/pcmcia/pcmcia_cis.c | 11 ++++------- 2 files changed, 8 insertions(+), 15 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 pcmcia/cistpl: Delete error messages for a failed memory allocation in three functions
From: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 22:12:00 +0100
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/pcmcia/cistpl.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/pcmcia/cistpl.c +4 -8
@@ -379,10 +379,9 @@ int verify_cis_cache(struct pcmcia_socket *s)return -EINVAL ; buf =kmalloc (256 ,GFP_KERNEL ); -if (buf =NULL ) { -dev_warn (&s->dev,"no memory for verifying CIS\n" ); +if (!buf)return -ENOMEM ; - } +mutex_lock (&s->ops_mutex);list_for_each_entry (cis, &s->cis_cache, node) {int len = cis->len;
@@ -419,7 +418,6 @@ int pcmcia_replace_cis(struct pcmcia_socket *s,kfree (s->fake_cis); s->fake_cis =kmalloc (len,GFP_KERNEL );if (s->fake_cis =NULL ) { -dev_warn (&s->dev,"no memory to replace CIS\n" );mutex_unlock (&s->ops_mutex);return -ENOMEM ; }
@@ -1395,14 +1393,12 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)mutex_unlock (&s->ops_mutex); tuple =kmalloc (sizeof (*tuple),GFP_KERNEL ); -if (tuple =NULL ) { -dev_warn (&s->dev,"no memory to validate CIS\n" ); +if (!tuple)return -ENOMEM ; - } + p =kmalloc (sizeof (*p),GFP_KERNEL );if (p =NULL ) {kfree (tuple); -dev_warn (&s->dev,"no memory to validate CIS\n" );return -ENOMEM ; }
Signature · 1 line
2.15.1
PATCH 2/3 pcmcia/cis: Delete an error message for a failed memory allocation in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 22:20:51 +0100
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/pcmcia/pcmcia_cis.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/pcmcia/pcmcia_cis.c +3 -6
@@ -43,10 +43,9 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,int ret; buf =kmalloc (256 ,GFP_KERNEL ); -if (buf =NULL ) { -dev_warn (&s->dev,"no memory to read tuple\n" ); +if (!buf)return -ENOMEM ; - } + tuple.DesiredTuple = code; tuple.Attributes =0 ;if (function =BIND_FN_ALL )
@@ -93,10 +92,8 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,int ret; buf =kzalloc (256 ,GFP_KERNEL ); -if (buf =NULL ) { -dev_warn (&s->dev,"no memory to read tuple\n" ); +if (!buf)return -ENOMEM ; - } tuple.TupleData = buf; tuple.TupleDataMax =255 ;
Signature · 1 line
2.15.1
PATCH 3/3 pcmcia/cis: Improve a size determination in pcmcia_loop_config()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 28 Dec 2017 22:30:42 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/pcmcia/pcmcia_cis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pcmcia/pcmcia_cis.c +1 -1
@@ -264,7 +264,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev,struct pcmcia_cfg_mem *cfg_mem;int ret; - cfg_mem =kzalloc (sizeof (struct pcmcia_cfg_mem ),GFP_KERNEL ); + cfg_mem =kzalloc (sizeof (*cfg_mem),GFP_KERNEL );if (cfg_mem =NULL )return -ENOMEM ;
Signature · 1 line
2.15.1