diff mbox

[OPW,kernel] staging: gdm724x: kzalloc should be used instead of kmalloc/memset

Message ID 1382480126-1682-1-git-send-email-teobaluta@gmail.com
State New, archived
Headers show

Commit Message

Teodora Baluta Oct. 22, 2013, 10:15 p.m. UTC
This patch fixes the following coccinelle warnings in driver gdm724x:

drivers/staging/gdm724x/gdm_usb.c:127:9-16: WARNING: kzalloc should be used for t_sdu, instead of kmalloc/memset
drivers/staging/gdm724x/gdm_usb.c:91:5-12: WARNING: kzalloc should be used for t, instead of kmalloc/memset

Signed-off-by: Teodora Baluta <teobaluta@gmail.com>
---
 drivers/staging/gdm724x/gdm_usb.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Waskiewicz Jr, Peter P Oct. 22, 2013, 10:32 p.m. UTC | #1
On Wed, 2013-10-23 at 01:15 +0300, Teodora Baluta wrote:
> This patch fixes the following coccinelle warnings in driver gdm724x:
> 
> drivers/staging/gdm724x/gdm_usb.c:127:9-16: WARNING: kzalloc should be used for t_sdu, instead of kmalloc/memset
> drivers/staging/gdm724x/gdm_usb.c:91:5-12: WARNING: kzalloc should be used for t, instead of kmalloc/memset
> 
> Signed-off-by: Teodora Baluta <teobaluta@gmail.com>

Reviewed-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>

> ---
>  drivers/staging/gdm724x/gdm_usb.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
> index bdc9637..781134a 100644
> --- a/drivers/staging/gdm724x/gdm_usb.c
> +++ b/drivers/staging/gdm724x/gdm_usb.c
> @@ -88,12 +88,11 @@ static struct usb_tx *alloc_tx_struct(int len)
>  	struct usb_tx *t = NULL;
>  	int ret = 0;
>  
> -	t = kmalloc(sizeof(struct usb_tx), GFP_ATOMIC);
> +	t = kzalloc(sizeof(struct usb_tx), GFP_ATOMIC);
>  	if (!t) {
>  		ret = -ENOMEM;
>  		goto out;
>  	}
> -	memset(t, 0, sizeof(struct usb_tx));
>  
>  	t->urb = usb_alloc_urb(0, GFP_ATOMIC);
>  	if (!(len % 512))
> @@ -124,12 +123,11 @@ static struct usb_tx_sdu *alloc_tx_sdu_struct(void)
>  	int ret = 0;
>  
> 
> -	t_sdu = kmalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC);
> +	t_sdu = kzalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC);
>  	if (!t_sdu) {
>  		ret = -ENOMEM;
>  		goto out;
>  	}
> -	memset(t_sdu, 0, sizeof(struct usb_tx_sdu));
>  
>  	t_sdu->buf = kmalloc(SDU_BUF_SIZE, GFP_ATOMIC);
>  	if (!t_sdu->buf) {
> -- 
> 1.7.10.4
>
diff mbox

Patch

diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
index bdc9637..781134a 100644
--- a/drivers/staging/gdm724x/gdm_usb.c
+++ b/drivers/staging/gdm724x/gdm_usb.c
@@ -88,12 +88,11 @@  static struct usb_tx *alloc_tx_struct(int len)
 	struct usb_tx *t = NULL;
 	int ret = 0;
 
-	t = kmalloc(sizeof(struct usb_tx), GFP_ATOMIC);
+	t = kzalloc(sizeof(struct usb_tx), GFP_ATOMIC);
 	if (!t) {
 		ret = -ENOMEM;
 		goto out;
 	}
-	memset(t, 0, sizeof(struct usb_tx));
 
 	t->urb = usb_alloc_urb(0, GFP_ATOMIC);
 	if (!(len % 512))
@@ -124,12 +123,11 @@  static struct usb_tx_sdu *alloc_tx_sdu_struct(void)
 	int ret = 0;
 
 
-	t_sdu = kmalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC);
+	t_sdu = kzalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC);
 	if (!t_sdu) {
 		ret = -ENOMEM;
 		goto out;
 	}
-	memset(t_sdu, 0, sizeof(struct usb_tx_sdu));
 
 	t_sdu->buf = kmalloc(SDU_BUF_SIZE, GFP_ATOMIC);
 	if (!t_sdu->buf) {