[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140515153342.14a5d34b@canb.auug.org.au>
Date: Thu, 15 May 2014 15:33:42 +1000
From: Stephen Rothwell <sfr@...b.auug.org.au>
To: Rusty Russell <rusty@...tcorp.com.au>
Cc: Amos Kong <akong@...hat.com>, linux-kernel@...r.kernel.org
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@...b.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@...b.auug.org.au
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists