lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240703194533.5a00ea5d@kernel.org>
Date: Wed, 3 Jul 2024 19:45:33 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Breno Leitao <leitao@...ian.org>
Cc: horia.geanta@....com, pankaj.gupta@....com, gaurav.jain@....com,
 linux-crypto@...r.kernel.org, Herbert Xu <herbert@...dor.apana.org.au>,
 "David S. Miller" <davem@...emloft.net>, horms@...nel.org,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3 3/4] crypto: caam: Unembed net_dev structure
 from qi

On Tue,  2 Jul 2024 11:55:53 -0700 Breno Leitao wrote:
> +static void free_caam_qi_pcpu_netdev(const cpumask_t *cpus)
> +{
> +	struct caam_qi_pcpu_priv *priv;
> +	int i;
> +
> +	for_each_cpu(i, cpus) {
> +		priv = per_cpu_ptr(&pcpu_qipriv, i);
> +		free_netdev(priv->net_dev);
> +	}
> +}
> +
>  int caam_qi_init(struct platform_device *caam_pdev)
>  {
>  	int err, i;
>  	struct device *ctrldev = &caam_pdev->dev, *qidev;
>  	struct caam_drv_private *ctrlpriv;
>  	const cpumask_t *cpus = qman_affine_cpus();
> +	cpumask_t clean_mask;
>  
>  	ctrlpriv = dev_get_drvdata(ctrldev);
>  	qidev = ctrldev;
> @@ -743,6 +756,8 @@ int caam_qi_init(struct platform_device *caam_pdev)
>  		return err;
>  	}
>  
> +	cpumask_clear(&clean_mask);
> +
>  	/*
>  	 * Enable the NAPI contexts on each of the core which has an affine
>  	 * portal.
> @@ -751,10 +766,16 @@ int caam_qi_init(struct platform_device *caam_pdev)
>  		struct caam_qi_pcpu_priv *priv = per_cpu_ptr(&pcpu_qipriv, i);
>  		struct caam_napi *caam_napi = &priv->caam_napi;
>  		struct napi_struct *irqtask = &caam_napi->irqtask;
> -		struct net_device *net_dev = &priv->net_dev;
> +		struct net_device *net_dev;
>  
> +		net_dev = alloc_netdev_dummy(0);
> +		if (!net_dev) {
> +			err = -ENOMEM;
> +			goto fail;

free_netdev() doesn't take NULL, free_caam_qi_pcpu_netdev()
will feed it one if we fail here

> +		}
> +		cpumask_set_cpu(i, &clean_mask);
> +		priv->net_dev = net_dev;
>  		net_dev->dev = *qidev;
> -		INIT_LIST_HEAD(&net_dev->napi_list);
>  
>  		netif_napi_add_tx_weight(net_dev, irqtask, caam_qi_poll,
>  					 CAAM_NAPI_WEIGHT);
> @@ -766,16 +787,22 @@ int caam_qi_init(struct platform_device *caam_pdev)
>  				     dma_get_cache_alignment(), 0, NULL);
>  	if (!qi_cache) {
>  		dev_err(qidev, "Can't allocate CAAM cache\n");
> -		free_rsp_fqs();
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto fail2;
>  	}
>  
>  	caam_debugfs_qi_init(ctrlpriv);
>  
>  	err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv);
>  	if (err)
> -		return err;
> +		goto fail2;
>  
>  	dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n");
>  	return 0;
> +
> +fail2:
> +	free_rsp_fqs();
> +fail:
> +	free_caam_qi_pcpu_netdev(&clean_mask);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ