* [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const
@ 2014-05-15 5:31 Stephen Rothwell
2014-05-15 5:33 ` [PATCH 2/2] virtio-rng: some small tidy ups around kmalloc Stephen Rothwell
2014-05-19 0:00 ` [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Rusty Russell
0 siblings, 2 replies; 4+ messages in thread
From: Stephen Rothwell @ 2014-05-15 5:31 UTC (permalink / raw)
To: Rusty Russell; +Cc: Amos Kong, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
drivers/char/hw_random/virtio-rng.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Based on the current virtio tree in linux-next.
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 12e242bbb0f5..6319b133b7aa 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -94,9 +94,11 @@ static int probe_common(struct virtio_device *vdev)
{
int err, i;
struct virtrng_info *vi = NULL;
+ char *name;
vi = kmalloc(sizeof(struct virtrng_info), GFP_KERNEL);
- vi->hwrng.name = kmalloc(40, GFP_KERNEL);
+ name = kmalloc(40, GFP_KERNEL);
+ vi->hwrng.name = name;
init_completion(&vi->have_data);
vi->hwrng.read = virtio_read;
@@ -117,7 +119,7 @@ static int probe_common(struct virtio_device *vdev)
i = 0;
do {
- sprintf(vi->hwrng.name, "virtio_rng.%d", i++);
+ sprintf(name, "virtio_rng.%d", i++);
err = hwrng_register(&vi->hwrng);
} while (err == -EEXIST);
--
2.0.0.rc2
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] virtio-rng: some small tidy ups around kmalloc
2014-05-15 5:31 [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Stephen Rothwell
@ 2014-05-15 5:33 ` Stephen Rothwell
2014-05-19 0:00 ` [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Rusty Russell
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2014-05-15 5:33 UTC (permalink / raw)
To: Rusty Russell; +Cc: Amos Kong, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const
2014-05-15 5:31 [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Stephen Rothwell
2014-05-15 5:33 ` [PATCH 2/2] virtio-rng: some small tidy ups around kmalloc Stephen Rothwell
@ 2014-05-19 0:00 ` Rusty Russell
2014-05-19 1:55 ` Stephen Rothwell
1 sibling, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2014-05-19 0:00 UTC (permalink / raw)
To: Stephen Rothwell; +Cc: Amos Kong, linux-kernel, Sasha Levin
Stephen Rothwell <sfr@canb.auug.org.au> writes:
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
> drivers/char/hw_random/virtio-rng.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Based on the current virtio tree in linux-next.
Actually, Sasha Levin did a nice cleanup which replaces these two,
and restores the const.
I've applied them, so you should have it in today's linux-next.
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const
2014-05-19 0:00 ` [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Rusty Russell
@ 2014-05-19 1:55 ` Stephen Rothwell
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2014-05-19 1:55 UTC (permalink / raw)
To: Rusty Russell; +Cc: Amos Kong, linux-kernel, Sasha Levin
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
Hi Rusty,
On Mon, 19 May 2014 09:30:53 +0930 Rusty Russell <rusty@rustcorp.com.au> wrote:
>
> Stephen Rothwell <sfr@canb.auug.org.au> writes:
> > Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > ---
> > drivers/char/hw_random/virtio-rng.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > Based on the current virtio tree in linux-next.
>
> Actually, Sasha Levin did a nice cleanup which replaces these two,
> and restores the const.
>
> I've applied them, so you should have it in today's linux-next.
Yep, saw that. Thanks.
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-19 1:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 5:31 [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Stephen Rothwell
2014-05-15 5:33 ` [PATCH 2/2] virtio-rng: some small tidy ups around kmalloc Stephen Rothwell
2014-05-19 0:00 ` [PATCH 1/2] virtio-rng: cope if struct hwrng.name is changed to const Rusty Russell
2014-05-19 1:55 ` Stephen Rothwell
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.