Message ID | 20220930114335.608894-1-praghadeeshthevendria@gmail.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | net: ethernet/mellanox: fix dereference before null check | expand |
On Fri, Sep 30, 2022 at 05:13:35PM +0530, Praghadeesh T K S wrote: > net: ethernet/mellanox: fix dereference before null check > macsec dereferenced before null check > bug identified by coverity's linux-next weekly scan > Coverity CID No: 1525317 > > Signed-off-by: Praghadeesh T K S <praghadeeshthevendria@gmail.com> > --- > drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c > index 5da746d..e822c2a 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c > @@ -1846,11 +1846,11 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv) > void mlx5e_macsec_cleanup(struct mlx5e_priv *priv) > { > struct mlx5e_macsec *macsec = priv->macsec; > - struct mlx5_core_dev *mdev = macsec->mdev; > > if (!macsec) > return; > > + struct mlx5_core_dev *mdev = macsec->mdev; > mlx5_notifier_unregister(mdev, &macsec->nb); > > mlx5e_macsec_fs_cleanup(macsec->macsec_fs); Always test-build your changes before you get a grumpy maintainer asking why you didn't test-build your changes... Also, the original code is just fine, Coverity is wrong here, don't you think? Look at the output of what the code is doing please... thanks, greg k-h
Hi Praghadeesh, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on net-next/master] [also build test WARNING on next-20220929] [cannot apply to net/master linus/master v6.0-rc7] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Praghadeesh-T-K-S/net-ethernet-mellanox-fix-dereference-before-null-check/20220930-194848 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 10c2aba89cc0535b23ebc795f44b8b8b16785ec9 config: s390-allyesconfig compiler: s390-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/b435d653648a9712105eb8d3c65fb3a0b301ab0e git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Praghadeesh-T-K-S/net-ethernet-mellanox-fix-dereference-before-null-check/20220930-194848 git checkout b435d653648a9712105eb8d3c65fb3a0b301ab0e # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash drivers/net/ethernet/mellanox/mlx5/core/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c: In function 'mlx5e_macsec_cleanup': >> drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c:1853:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 1853 | struct mlx5_core_dev *mdev = macsec->mdev; | ^~~~~~ vim +1853 drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c 1845 1846 void mlx5e_macsec_cleanup(struct mlx5e_priv *priv) 1847 { 1848 struct mlx5e_macsec *macsec = priv->macsec; 1849 1850 if (!macsec) 1851 return; 1852 > 1853 struct mlx5_core_dev *mdev = macsec->mdev;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c index 5da746d..e822c2a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -1846,11 +1846,11 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv) void mlx5e_macsec_cleanup(struct mlx5e_priv *priv) { struct mlx5e_macsec *macsec = priv->macsec; - struct mlx5_core_dev *mdev = macsec->mdev; if (!macsec) return; + struct mlx5_core_dev *mdev = macsec->mdev; mlx5_notifier_unregister(mdev, &macsec->nb); mlx5e_macsec_fs_cleanup(macsec->macsec_fs);
net: ethernet/mellanox: fix dereference before null check macsec dereferenced before null check bug identified by coverity's linux-next weekly scan Coverity CID No: 1525317 Signed-off-by: Praghadeesh T K S <praghadeeshthevendria@gmail.com> --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)