lkml.org 
[lkml]   [2014]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] virtio-rng: some small tidy ups around kmalloc
Include slab.h for kmalloc/kfree declaration and check the actual
allocations succeed.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
drivers/char/hw_random/virtio-rng.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 6319b133b7aa..73d7fc42d1a7 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -24,6 +24,7 @@
#include <linux/virtio.h>
#include <linux/virtio_rng.h>
#include <linux/module.h>
+#include <linux/slab.h>


struct virtrng_info {
@@ -97,7 +98,13 @@ static int probe_common(struct virtio_device *vdev)
char *name;

vi = kmalloc(sizeof(struct virtrng_info), GFP_KERNEL);
+ if (!vi)
+ return -ENOMEM;
name = kmalloc(40, GFP_KERNEL);
+ if (!name) {
+ kfree(vi);
+ return -ENOMEM;
+ }
vi->hwrng.name = name;
init_completion(&vi->have_data);

--
2.0.0.rc2
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2014-05-15 08:01    [W:0.060 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site