Re: [PATCH net-next 6/8] net:openvswitch: add psample support

From: Dan Carpenter
Date: Tue Apr 30 2024 - 03:32:27 EST


Hi Adrian,

kernel test robot noticed the following build warnings:

url: https://github.com/intel-lab-lkp/linux/commits/Adrian-Moreno/net-netlink-export-genl-private-pointer-getters/20240424-215821
base: net-next/main
patch link: https://lore.kernel.org/r/20240424135109.3524355-7-amorenoz%40redhat.com
patch subject: [PATCH net-next 6/8] net:openvswitch: add psample support
config: i386-randconfig-141-20240430 (https://download.01.org/0day-ci/archive/20240430/202404300611.kJOZL2KI-lkp@xxxxxxxxx/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202404300611.kJOZL2KI-lkp@xxxxxxxxx/

New smatch warnings:
net/openvswitch/actions.c:1097 sample() error: uninitialized symbol 'ret'.

vim +/ret +1097 net/openvswitch/actions.c

ccb1352e76cff0 Jesse Gross 2011-10-25 1061 static int sample(struct datapath *dp, struct sk_buff *skb,
ccea74457bbdaf Neil McKee 2015-05-26 1062 struct sw_flow_key *key, const struct nlattr *attr,
798c166173ffb5 andy zhou 2017-03-20 1063 bool last)
ccb1352e76cff0 Jesse Gross 2011-10-25 1064 {
ccc0b9e4657efd Adrian Moreno 2024-04-24 1065 const struct sample_arg *arg;
798c166173ffb5 andy zhou 2017-03-20 1066 struct nlattr *sample_arg;
798c166173ffb5 andy zhou 2017-03-20 1067 int rem = nla_len(attr);
ccc0b9e4657efd Adrian Moreno 2024-04-24 1068 struct nlattr *actions;
bef7f7567a104a andy zhou 2017-03-20 1069 bool clone_flow_key;
ccc0b9e4657efd Adrian Moreno 2024-04-24 1070 int ret;
ccb1352e76cff0 Jesse Gross 2011-10-25 1071
798c166173ffb5 andy zhou 2017-03-20 1072 /* The first action is always 'OVS_SAMPLE_ATTR_ARG'. */
798c166173ffb5 andy zhou 2017-03-20 1073 sample_arg = nla_data(attr);
798c166173ffb5 andy zhou 2017-03-20 1074 arg = nla_data(sample_arg);
798c166173ffb5 andy zhou 2017-03-20 1075 actions = nla_next(sample_arg, &rem);
e05176a3283822 Wenyu Zhang 2015-08-05 1076
798c166173ffb5 andy zhou 2017-03-20 1077 if ((arg->probability != U32_MAX) &&
a251c17aa558d8 Jason A. Donenfeld 2022-10-05 1078 (!arg->probability || get_random_u32() > arg->probability)) {
798c166173ffb5 andy zhou 2017-03-20 1079 if (last)
9d802da40b7c82 Adrian Moreno 2023-08-11 1080 ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);
ccb1352e76cff0 Jesse Gross 2011-10-25 1081 return 0;
ccb1352e76cff0 Jesse Gross 2011-10-25 1082 }
651887b0c22cff Simon Horman 2014-07-21 1083
ccc0b9e4657efd Adrian Moreno 2024-04-24 1084 if (arg->flags & OVS_SAMPLE_ARG_FLAG_PSAMPLE) {
ccc0b9e4657efd Adrian Moreno 2024-04-24 1085 ret = ovs_psample_packet(dp, key, arg, skb);
ccc0b9e4657efd Adrian Moreno 2024-04-24 1086 if (ret)
ccc0b9e4657efd Adrian Moreno 2024-04-24 1087 return ret;
ccc0b9e4657efd Adrian Moreno 2024-04-24 1088 }
ccc0b9e4657efd Adrian Moreno 2024-04-24 1089
ccc0b9e4657efd Adrian Moreno 2024-04-24 1090 if (nla_ok(actions, rem)) {
ccc0b9e4657efd Adrian Moreno 2024-04-24 1091 clone_flow_key = !(arg->flags & OVS_SAMPLE_ARG_FLAG_EXEC);
ccc0b9e4657efd Adrian Moreno 2024-04-24 1092 ret = clone_execute(dp, skb, key, 0, actions, rem, last,
bef7f7567a104a andy zhou 2017-03-20 1093 clone_flow_key);
ccc0b9e4657efd Adrian Moreno 2024-04-24 1094 } else if (last) {
ccc0b9e4657efd Adrian Moreno 2024-04-24 1095 ovs_kfree_skb_reason(skb, OVS_DROP_LAST_ACTION);

ret is uninitialized on this last path.

ccc0b9e4657efd Adrian Moreno 2024-04-24 1096 }
ccc0b9e4657efd Adrian Moreno 2024-04-24 @1097 return ret;
971427f353f3c4 Andy Zhou 2014-09-15 1098 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki