Re: [PATCH] hwrng: core - Allocate memory during module init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Sun, Sep 04, 2016 at 01:59:38PM +0530, PrasannaKumar Muralidharan wrote:
>>
>> @@ -573,6 +557,17 @@ EXPORT_SYMBOL_GPL(devm_hwrng_unregister);
>>
>>  static int __init hwrng_modinit(void)
>>  {
>> +     /* kmalloc makes this safe for virt_to_page() in virtio_rng.c */
>> +     rng_buffer = kmalloc(rng_buffer_size(), GFP_KERNEL);
>> +     if (!rng_buffer)
>> +             return -ENOMEM;
>> +
>> +     rng_fillbuf = kmalloc(rng_buffer_size(), GFP_KERNEL);
>> +     if (!rng_fillbuf) {
>> +             kfree(rng_buffer);
>> +             return -ENOMEM;
>> +     }
>> +
>>       return register_miscdev();
>
> You're leaking memory if register_miscdev fails.

Ah, yes! I can send a revised patch.
Do you think allocating rng_buffer, rng_fillbuf in module init useful?
If not there is no point in sending a new patch with fix.

Thanks,
PrasannaKumar
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux