mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] PCMCIA-CIS: Adjustments for six function implementations
@ 2017-12-28 21:44 SF Markus Elfring
  2017-12-28 21:45 ` [PATCH 1/3] pcmcia/cistpl: Delete error messages for a failed memory allocation in three functions SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-12-28 21:44 UTC (permalink / raw)
  To: linux-pcmcia, Bhumika Goyal, Greg Kroah-Hartman; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] pcmcia/cistpl: Delete error messages for a failed memory allocation in three functions
  2017-12-28 21:44 [PATCH 0/3] PCMCIA-CIS: Adjustments for six function implementations SF Markus Elfring
@ 2017-12-28 21:45 ` SF Markus Elfring
  2017-12-28 21:46 ` [PATCH 2/3] pcmcia/cis: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
  2017-12-28 21:48 ` [PATCH 3/3] pcmcia/cis: Improve a size determination in pcmcia_loop_config() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-12-28 21:45 UTC (permalink / raw)
  To: linux-pcmcia, Bhumika Goyal, Greg Kroah-Hartman; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pcmcia/cistpl.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 102646fedb56..192c0e8e9c3d 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -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;
 	}
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] pcmcia/cis: Delete an error message for a failed memory allocation in two functions
  2017-12-28 21:44 [PATCH 0/3] PCMCIA-CIS: Adjustments for six function implementations SF Markus Elfring
  2017-12-28 21:45 ` [PATCH 1/3] pcmcia/cistpl: Delete error messages for a failed memory allocation in three functions SF Markus Elfring
@ 2017-12-28 21:46 ` SF Markus Elfring
  2017-12-28 21:48 ` [PATCH 3/3] pcmcia/cis: Improve a size determination in pcmcia_loop_config() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-12-28 21:46 UTC (permalink / raw)
  To: linux-pcmcia, Bhumika Goyal, Greg Kroah-Hartman; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pcmcia/pcmcia_cis.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/pcmcia/pcmcia_cis.c b/drivers/pcmcia/pcmcia_cis.c
index 1c05d74e850d..ffcd014b7bc1 100644
--- a/drivers/pcmcia/pcmcia_cis.c
+++ b/drivers/pcmcia/pcmcia_cis.c
@@ -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;
-- 
2.15.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] pcmcia/cis: Improve a size determination in pcmcia_loop_config()
  2017-12-28 21:44 [PATCH 0/3] PCMCIA-CIS: Adjustments for six function implementations SF Markus Elfring
  2017-12-28 21:45 ` [PATCH 1/3] pcmcia/cistpl: Delete error messages for a failed memory allocation in three functions SF Markus Elfring
  2017-12-28 21:46 ` [PATCH 2/3] pcmcia/cis: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
@ 2017-12-28 21:48 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-12-28 21:48 UTC (permalink / raw)
  To: linux-pcmcia, Bhumika Goyal, Greg Kroah-Hartman; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pcmcia/pcmcia_cis.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pcmcia/pcmcia_cis.c b/drivers/pcmcia/pcmcia_cis.c
index ffcd014b7bc1..ecee94e8f30a 100644
--- a/drivers/pcmcia/pcmcia_cis.c
+++ b/drivers/pcmcia/pcmcia_cis.c
@@ -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;
 
-- 
2.15.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-28 21:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-28 21:44 [PATCH 0/3] PCMCIA-CIS: Adjustments for six function implementations SF Markus Elfring
2017-12-28 21:45 ` [PATCH 1/3] pcmcia/cistpl: Delete error messages for a failed memory allocation in three functions SF Markus Elfring
2017-12-28 21:46 ` [PATCH 2/3] pcmcia/cis: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-12-28 21:48 ` [PATCH 3/3] pcmcia/cis: Improve a size determination in pcmcia_loop_config() SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome