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

From: Jakub Kicinski
Date: Mon Oct 26 2020 - 14:46:39 EST


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.