[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f276c92f-f112-ed47-30c6-d41211804eb7@huawei.com>
Date: Tue, 14 May 2019 22:42:54 +0800
From: YueHaibing <yuehaibing@...wei.com>
To: Guillaume Nault <gnault@...hat.com>
CC: <davem@...emloft.net>, <paulus@...ba.org>,
<linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>
Subject: Re: [PATCH] ppp: deflate: Fix possible crash in deflate_init
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@...wei.com>
>> Signed-off-by: YueHaibing <yuehaibing@...wei.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!
>
> .
>
Powered by blists - more mailing lists