lkml.org 
[lkml]   [2019]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ppp: deflate: Fix possible crash in deflate_init
From
Date
On 2019/5/14 22:05, Guillaume Nault wrote:
> On Tue, May 14, 2019 at 03:43:00PM +0800, YueHaibing wrote:
>>
>> If ppp_deflate fails to register in deflate_init,
>> module initialization failed out, however
>> ppp_deflate_draft may has been regiestred and not
>> unregistered before return.
>> Then the seconed modprobe will trigger crash like this.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>> drivers/net/ppp/ppp_deflate.c | 14 +++++++++-----
>> 1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ppp/ppp_deflate.c b/drivers/net/ppp/ppp_deflate.c
>> index b5edc7f..2829efe 100644
>> --- a/drivers/net/ppp/ppp_deflate.c
>> +++ b/drivers/net/ppp/ppp_deflate.c
>> @@ -610,12 +610,16 @@ static void z_incomp(void *arg, unsigned char *ibuf, int icnt)
>>
>> static int __init deflate_init(void)
>> {
>> - int answer = ppp_register_compressor(&ppp_deflate);
>> - if (answer == 0)
>> - printk(KERN_INFO
>> - "PPP Deflate Compression module registered\n");
>> + int answer;
>> +
>> + answer = ppp_register_compressor(&ppp_deflate);
>> + if (answer)
>> + return answer;
>> +
>> + pr_info("PPP Deflate Compression module registered\n");
>> ppp_register_compressor(&ppp_deflate_draft);
>> - return answer;
>> +
>> + return 0;
>> }
>>
> I'd be cleaner to also check for ppp_deflate_draft registration failure
> IMHO (and print the log line only if both compressors get registered
> successfully).

Ok, will send v2 to do that, thanks!

>
> .
>

\
 
 \ /
  Last update: 2019-05-14 16:43    [W:0.048 / U:1.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site