staging/wlan-ng/prism2fw: Adjustments for two function implementations
Subsystems (2)
cover staging/wlan-ng/prism2fw: Adjustments for two function implementations
From: Markus Elfring <[email protected]>
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(-)
Signature · 1 line
2.15.1
PATCH 1/4 staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage()
From: Markus Elfring <[email protected]>
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.
--- drivers/staging/wlan-ng/prism2fw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/wlan-ng/prism2fw.c +2 -3
@@ -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); }
Signature · 1 line
2.15.1
PATCH 2/4 staging/wlan-ng/prism2fw: Use a known error code after a failed kzalloc() in mkimage()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/staging/wlan-ng/prism2fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/prism2fw.c +1 -1
@@ -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);
Signature · 1 line
2.15.1
PATCH 3/4 staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in writeimage()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 13 Dec 2017 13:28:15 +0100
Omit an extra message for a memory allocation failure in this function.
--- drivers/staging/wlan-ng/prism2fw.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/wlan-ng/prism2fw.c +0 -3
@@ -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 ; }
Signature · 1 line
2.15.1
PATCH 4/4 staging/wlan-ng/prism2fw: Use common error handling code in writeimage()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- drivers/staging/wlan-ng/prism2fw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/wlan-ng/prism2fw.c +2 -3
@@ -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 */
Signature · 1 line
2.15.1