All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: unisys: visornic_main: Replace kzalloc with kcalloc
@ 2015-10-13 15:41 Shivani Bhardwaj
  2015-10-13 15:52 ` [Outreachy kernel] " Shraddha Barke
  0 siblings, 1 reply; 2+ messages in thread
From: Shivani Bhardwaj @ 2015-10-13 15:41 UTC (permalink / raw)
  To: outreachy-kernel

Use kcalloc instead of kzalloc for allocation of array as it prevents
integer overflow.
Semantic patch used:

@@
expression E1,E2,E3;
@@

- kzalloc(E1*sizeof(E2),E3)
+ kcalloc(E1,sizeof(E2),E3)

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
 drivers/staging/unisys/visornic/visornic_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
index 85c9fec..6db74de 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -1797,8 +1797,8 @@ static int visornic_probe(struct visor_device *dev)
 		goto cleanup_netdev;
 	}
 
-	devdata->rcvbuf = kzalloc(sizeof(struct sk_buff *) *
-				  devdata->num_rcv_bufs, GFP_KERNEL);
+	devdata->rcvbuf = kcalloc(devdata->num_rcv_bufs,
+				  sizeof(struct sk_buff *), GFP_KERNEL);
 	if (!devdata->rcvbuf) {
 		err = -ENOMEM;
 		goto cleanup_rcvbuf;
-- 
2.1.0



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

* Re: [Outreachy kernel] [PATCH] Staging: unisys: visornic_main: Replace kzalloc with kcalloc
  2015-10-13 15:41 [PATCH] Staging: unisys: visornic_main: Replace kzalloc with kcalloc Shivani Bhardwaj
@ 2015-10-13 15:52 ` Shraddha Barke
  0 siblings, 0 replies; 2+ messages in thread
From: Shraddha Barke @ 2015-10-13 15:52 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: outreachy-kernel



On Tue, 13 Oct 2015, Shivani Bhardwaj wrote:

> Use kcalloc instead of kzalloc for allocation of array as it prevents
> integer overflow.
> Semantic patch used:
>
> @@
> expression E1,E2,E3;
> @@
>
> - kzalloc(E1*sizeof(E2),E3)
> + kcalloc(E1,sizeof(E2),E3)
>
> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> ---
> drivers/staging/unisys/visornic/visornic_main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Hello, this has already been done.I think you should update your 
staging-testing branch

Shraddha
>
> diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
> index 85c9fec..6db74de 100644
> --- a/drivers/staging/unisys/visornic/visornic_main.c
> +++ b/drivers/staging/unisys/visornic/visornic_main.c
> @@ -1797,8 +1797,8 @@ static int visornic_probe(struct visor_device *dev)
> 		goto cleanup_netdev;
> 	}
>
> -	devdata->rcvbuf = kzalloc(sizeof(struct sk_buff *) *
> -				  devdata->num_rcv_bufs, GFP_KERNEL);
> +	devdata->rcvbuf = kcalloc(devdata->num_rcv_bufs,
> +				  sizeof(struct sk_buff *), GFP_KERNEL);
> 	if (!devdata->rcvbuf) {
> 		err = -ENOMEM;
> 		goto cleanup_rcvbuf;
> -- 
> 2.1.0
>
> -- 
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151013154113.GA28785%40ubuntu.
> For more options, visit https://groups.google.com/d/optout.
>


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

end of thread, other threads:[~2015-10-13 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 15:41 [PATCH] Staging: unisys: visornic_main: Replace kzalloc with kcalloc Shivani Bhardwaj
2015-10-13 15:52 ` [Outreachy kernel] " Shraddha Barke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.