drivers/net/ethernet/mellanox/mlx5/core/fs_core.c:1555 dest_is_valid() error: we previously assumed 'dest' could be null (see line 1545)

From: Dan Carpenter
Date: Fri Sep 11 2020 - 06:35:12 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 581cb3a26baf846ee9636214afaa5333919875b1
commit: ff189b43568216c6211e9e7ddd9026cb8295e744 net/mlx5: Add ignore level support fwd to table rules
config: powerpc-randconfig-m031-20200911 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c:1555 dest_is_valid() error: we previously assumed 'dest' could be null (see line 1545)

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ff189b43568216c6211e9e7ddd9026cb8295e744
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout ff189b43568216c6211e9e7ddd9026cb8295e744
vim +/dest +1555 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

d63cd28608bb563 Maor Gottlieb 2016-04-29 1538 static bool dest_is_valid(struct mlx5_flow_destination *dest,
ff189b43568216c Paul Blakey 2020-01-05 1539 struct mlx5_flow_act *flow_act,
d63cd28608bb563 Maor Gottlieb 2016-04-29 1540 struct mlx5_flow_table *ft)
d63cd28608bb563 Maor Gottlieb 2016-04-29 1541 {
ff189b43568216c Paul Blakey 2020-01-05 1542 bool ignore_level = flow_act->flags & FLOW_ACT_IGNORE_FLOW_LEVEL;
ff189b43568216c Paul Blakey 2020-01-05 1543 u32 action = flow_act->action;
ff189b43568216c Paul Blakey 2020-01-05 1544
bd5251dbf156b6b Amir Vadai 2016-05-13 @1545 if (dest && (dest->type == MLX5_FLOW_DESTINATION_TYPE_COUNTER))
^^^^
Check for NULL.

171c7625bef9998 Mark Bloch 2018-10-03 1546 return counter_is_valid(action);
bd5251dbf156b6b Amir Vadai 2016-05-13 1547
d63cd28608bb563 Maor Gottlieb 2016-04-29 1548 if (!(action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST))
d63cd28608bb563 Maor Gottlieb 2016-04-29 1549 return true;
d63cd28608bb563 Maor Gottlieb 2016-04-29 1550
ff189b43568216c Paul Blakey 2020-01-05 1551 if (ignore_level) {
ff189b43568216c Paul Blakey 2020-01-05 1552 if (ft->type != FS_FT_FDB)
ff189b43568216c Paul Blakey 2020-01-05 1553 return false;
ff189b43568216c Paul Blakey 2020-01-05 1554
ff189b43568216c Paul Blakey 2020-01-05 @1555 if (dest->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE &&
^^^^^^^^^^
Unchecked dereference.

ff189b43568216c Paul Blakey 2020-01-05 1556 dest->ft->type != FS_FT_FDB)
ff189b43568216c Paul Blakey 2020-01-05 1557 return false;
ff189b43568216c Paul Blakey 2020-01-05 1558 }
ff189b43568216c Paul Blakey 2020-01-05 1559
d63cd28608bb563 Maor Gottlieb 2016-04-29 1560 if (!dest || ((dest->type ==
^^^^^
Check.

d63cd28608bb563 Maor Gottlieb 2016-04-29 1561 MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE) &&
ff189b43568216c Paul Blakey 2020-01-05 1562 (dest->ft->level <= ft->level && !ignore_level)))
d63cd28608bb563 Maor Gottlieb 2016-04-29 1563 return false;
d63cd28608bb563 Maor Gottlieb 2016-04-29 1564 return true;
d63cd28608bb563 Maor Gottlieb 2016-04-29 1565 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip