[PATCH v2 net] gtp: fix an use-before-init in gtp_newlink()

Jakub Kicinski kuba at kernel.org
Mon Oct 26 18:46:33 UTC 2020


On Mon, 26 Oct 2020 16:22:27 +0900 Masahiro Fujiwara wrote:
> v2:
>  - leave out_hashtable: label for clarity (Jakub).
>  - fix code and comment styles.

Thanks!

> diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
> index 8e47d0112e5d..07cb6d9495e8 100644
> --- a/drivers/net/gtp.c
> +++ b/drivers/net/gtp.c
> @@ -663,10 +663,6 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
>  
>  	gtp = netdev_priv(dev);
>  
> -	err = gtp_encap_enable(gtp, data);
> -	if (err < 0)
> -		return err;
> -
>  	if (!data[IFLA_GTP_PDP_HASHSIZE]) {
>  		hashsize = 1024;
>  	} else {
> @@ -676,13 +672,17 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
>  	}
>  
>  	err = gtp_hashtable_new(gtp, hashsize);
> +	if (err < 0)
> +		return err;
> +
> +	err = gtp_encap_enable(gtp, data);
>  	if (err < 0)
>  		goto out_encap;

This needs to say goto out_hashtable; now.


More information about the osmocom-net-gprs mailing list