netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guillaume Nault <gnault@redhat.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: davem@davemloft.net, paulus@samba.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] ppp: deflate: Fix possible crash in deflate_init
Date: Tue, 14 May 2019 16:05:48 +0200	[thread overview]
Message-ID: <20190514140547.GA25993@linux.home> (raw)
In-Reply-To: <20190514074300.42588-1-yuehaibing@huawei.com>

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).

  reply	other threads:[~2019-05-14 14:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14  7:43 [PATCH] ppp: deflate: Fix possible crash in deflate_init YueHaibing
2019-05-14 14:05 ` Guillaume Nault [this message]
2019-05-14 14:42   ` YueHaibing
2019-05-14 14:55 ` [PATCH v2] " YueHaibing
2019-05-14 15:34   ` Guillaume Nault
2019-05-14 22:42   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190514140547.GA25993@linux.home \
    --to=gnault@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).