virtio-rng: cope if struct hwrng.name is changed to const
Subsystems (2)
PATCH 1/2 virtio-rng: cope if struct hwrng.name is changed to const
Signed-off-by Stephen Rothwell <[email protected]>
--- drivers/char/hw_random/virtio-rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Based on the current virtio tree in linux-next.
drivers/char/hw_random/virtio-rng.c +4 -2
@@ -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 );
Signature · 5 lines
2.0.0.rc2 -- Cheers, Stephen Rothwell [email protected]
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 <[email protected]>
--- drivers/char/hw_random/virtio-rng.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/char/hw_random/virtio-rng.c +7 -0
@@ -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);
Signature · 5 lines
2.0.0.rc2 -- Cheers, Stephen Rothwell [email protected]
Quoted 6 lines · Stephen Rothwell
Signed-off-by Stephen Rothwell <[email protected]>--- 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.
Hi Rusty,
Quoted 7 lines · On Mon, 19 May 2014 09:30:53 +0930 Rusty Russell <[email protected]> wrote:
Quoted 5 lines · Stephen Rothwell
Signed-off-by Stephen Rothwell <[email protected]>--- drivers/char/hw_random/virtio-rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 1 line
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.
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]