Skip to contentSkip to conversation

PCMCIA-CIS: Adjustments for six function implementations

PATCH New SF Markus Elfring 1 participant 4 messages Dec 28, 2017

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

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
#1 lore raw

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
index 102646fedb56..192c0e8e9c3d 100644
@@ -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
#2 lore raw

PATCH 2/3 pcmcia/cis: Delete an error message for a failed memory allocation in two functions

In reply to SF Markus Elfring

From: 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
index 1c05d74e850d..ffcd014b7bc1 100644
@@ -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
#3 lore raw

PATCH 3/3 pcmcia/cis: Improve a size determination in pcmcia_loop_config()

In reply to SF Markus Elfring

From: 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
index ffcd014b7bc1..ecee94e8f30a 100644
@@ -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