* [PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations
@ 2017-12-13 13:10 SF Markus Elfring
2017-12-13 13:11 ` [PATCH 1/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage() SF Markus Elfring
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-13 13:10 UTC (permalink / raw)
To: devel, Greg Kroah-Hartman, Maciek Borzecki, Simo Koskinen,
Thibaut Sautereau
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 13 Dec 2017 14:03:02 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (4):
Delete an error message for a failed memory allocation in mkimage()
Use a known error code after a failed kzalloc() in mkimage()
Delete an error message for a failed memory allocation in writeimage()
Use common error handling code in writeimage()
drivers/staging/wlan-ng/prism2fw.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
--
2.15.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage()
2017-12-13 13:10 [PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations SF Markus Elfring
@ 2017-12-13 13:11 ` SF Markus Elfring
2017-12-13 13:12 ` [PATCH 2/4] staging/wlan-ng/prism2fw: Use a known error code after a failed kzalloc() " SF Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-13 13:11 UTC (permalink / raw)
To: devel, Greg Kroah-Hartman, Maciek Borzecki, Simo Koskinen,
Thibaut Sautereau
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 13 Dec 2017 12:57:13 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/wlan-ng/prism2fw.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 344bec8cc31b..6888d1b093fa 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -557,10 +557,9 @@ static int mkimage(struct imgchunk *clist, unsigned int *ccnt)
/* Allocate buffer space for chunks */
for (i = 0; i < *ccnt; i++) {
clist[i].data = kzalloc(clist[i].len, GFP_KERNEL);
- if (!clist[i].data) {
- pr_err("failed to allocate image space, exitting.\n");
+ if (!clist[i].data)
return 1;
- }
+
pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
i, clist[i].addr, clist[i].len);
}
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] staging/wlan-ng/prism2fw: Use a known error code after a failed kzalloc() in mkimage()
2017-12-13 13:10 [PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations SF Markus Elfring
2017-12-13 13:11 ` [PATCH 1/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage() SF Markus Elfring
@ 2017-12-13 13:12 ` SF Markus Elfring
2017-12-13 13:13 ` [PATCH 3/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in writeimage() SF Markus Elfring
2017-12-13 13:14 ` [PATCH 4/4] staging/wlan-ng/prism2fw: Use common error handling code " SF Markus Elfring
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-13 13:12 UTC (permalink / raw)
To: devel, Greg Kroah-Hartman, Maciek Borzecki, Simo Koskinen,
Thibaut Sautereau
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 13 Dec 2017 13:20:10 +0100
Make a memory allocation failure clearer by using the error code "-ENOMEM"
(instead of the constant "1") in this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/wlan-ng/prism2fw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 6888d1b093fa..efca9108dad8 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -558,7 +558,7 @@ static int mkimage(struct imgchunk *clist, unsigned int *ccnt)
for (i = 0; i < *ccnt; i++) {
clist[i].data = kzalloc(clist[i].len, GFP_KERNEL);
if (!clist[i].data)
- return 1;
+ return -ENOMEM;
pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
i, clist[i].addr, clist[i].len);
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in writeimage()
2017-12-13 13:10 [PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations SF Markus Elfring
2017-12-13 13:11 ` [PATCH 1/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage() SF Markus Elfring
2017-12-13 13:12 ` [PATCH 2/4] staging/wlan-ng/prism2fw: Use a known error code after a failed kzalloc() " SF Markus Elfring
@ 2017-12-13 13:13 ` SF Markus Elfring
2017-12-13 13:14 ` [PATCH 4/4] staging/wlan-ng/prism2fw: Use common error handling code " SF Markus Elfring
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-13 13:13 UTC (permalink / raw)
To: devel, Greg Kroah-Hartman, Maciek Borzecki, Simo Koskinen,
Thibaut Sautereau
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 13 Dec 2017 13:28:15 +0100
Omit an extra message for a memory allocation failure in this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/wlan-ng/prism2fw.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index efca9108dad8..e6f7ed17106a 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -1014,9 +1014,6 @@ static int writeimage(struct wlandevice *wlandev, struct imgchunk *fchunk,
if (!rstmsg || !rwrmsg) {
kfree(rstmsg);
kfree(rwrmsg);
- netdev_err(wlandev->netdev,
- "%s: no memory for firmware download, aborting download\n",
- __func__);
return -ENOMEM;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] staging/wlan-ng/prism2fw: Use common error handling code in writeimage()
2017-12-13 13:10 [PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-12-13 13:13 ` [PATCH 3/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in writeimage() SF Markus Elfring
@ 2017-12-13 13:14 ` SF Markus Elfring
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-13 13:14 UTC (permalink / raw)
To: devel, Greg Kroah-Hartman, Maciek Borzecki, Simo Koskinen,
Thibaut Sautereau
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 13 Dec 2017 13:41:41 +0100
Replace two calls of the function "kfree" by a jump to the same statements
at the end of this function so that the generated object code could become
a bit smaller.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/wlan-ng/prism2fw.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index e6f7ed17106a..42ad5ff7772e 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -1012,9 +1012,8 @@ static int writeimage(struct wlandevice *wlandev, struct imgchunk *fchunk,
rstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL);
rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL);
if (!rstmsg || !rwrmsg) {
- kfree(rstmsg);
- kfree(rwrmsg);
- return -ENOMEM;
+ result = -ENOMEM;
+ goto free_result;
}
/* Initialize the messages */
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-12-13 13:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-13 13:10 [PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations SF Markus Elfring
2017-12-13 13:11 ` [PATCH 1/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage() SF Markus Elfring
2017-12-13 13:12 ` [PATCH 2/4] staging/wlan-ng/prism2fw: Use a known error code after a failed kzalloc() " SF Markus Elfring
2017-12-13 13:13 ` [PATCH 3/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in writeimage() SF Markus Elfring
2017-12-13 13:14 ` [PATCH 4/4] staging/wlan-ng/prism2fw: Use common error handling code " 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