On 22/02/2023 04:54, Dan Carpenter wrote:
Hello Pedro Tammela, The patch 288864effe33: "net/sched: act_connmark: transition to percpu stats and rcu" from Feb 14, 2023, leads to the following Smatch static checker warning: net/sched/act_connmark.c:167 tcf_connmark_init() error: uninitialized symbol 'ci'. net/sched/act_connmark.c 98 static int tcf_connmark_init(struct net *net, struct nlattr *nla, 99 struct nlattr *est, struct tc_action **a, 100 struct tcf_proto *tp, u32 flags, 101 struct netlink_ext_ack *extack) 102 { 103 struct tc_action_net *tn = net_generic(net, act_connmark_ops.net_id); 104 struct tcf_connmark_parms *nparms, *oparms; 105 struct nlattr *tb[TCA_CONNMARK_MAX + 1]; 106 bool bind = flags & TCA_ACT_FLAGS_BIND; 107 struct tcf_chain *goto_ch = NULL; 108 struct tcf_connmark_info *ci; 109 struct tc_connmark *parm; 110 int ret = 0, err; 111 u32 index; 112 113 if (!nla) 114 return -EINVAL; 115 116 ret = nla_parse_nested_deprecated(tb, TCA_CONNMARK_MAX, nla, 117 connmark_policy, NULL); 118 if (ret < 0) 119 return ret; 120 121 if (!tb[TCA_CONNMARK_PARMS]) 122 return -EINVAL; 123 124 nparms = kzalloc(sizeof(*nparms), GFP_KERNEL); 125 if (!nparms) 126 return -ENOMEM; 127 128 parm = nla_data(tb[TCA_CONNMARK_PARMS]); 129 index = parm->index; 130 ret = tcf_idr_check_alloc(tn, &index, a, bind); 131 if (!ret) { 132 ret = tcf_idr_create_from_flags(tn, index, est, a, 133 &act_connmark_ops, bind, flags); 134 if (ret) { 135 tcf_idr_cleanup(tn, index); 136 err = ret; 137 goto out_free; 138 } 139 140 ci = to_connmark(*a); 141 142 nparms->net = net; 143 nparms->zone = parm->zone; 144 145 ret = ACT_P_CREATED; 146 } else if (ret > 0) { 147 ci = to_connmark(*a); 148 if (bind) { 149 err = 0; 150 goto out_free; 151 } 152 if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 153 err = -EEXIST; 154 goto release_idr; 155 } 156 157 nparms->net = rtnl_dereference(ci->parms)->net; 158 nparms->zone = parm->zone; 159 160 ret = 0; 161 } ci not initialized if ret < 0. 162 163 err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); 164 if (err < 0) 165 goto release_idr; 166 --> 167 spin_lock_bh(&ci->tcf_lock); 168 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); 169 oparms = rcu_replace_pointer(ci->parms, nparms, lockdep_is_held(&ci->tcf_lock)); 170 spin_unlock_bh(&ci->tcf_lock); 171 172 if (goto_ch) 173 tcf_chain_put_by_act(goto_ch); 174 175 if (oparms) 176 kfree_rcu(oparms, rcu); 177 178 return ret; 179 180 release_idr: 181 tcf_idr_release(*a, bind); 182 out_free: 183 kfree(nparms); 184 return err; 185 } regards, dan carpenter
Hi Dan, Thanks for the report. I will send a fix shortly. Is `make C=2` enough to catch these warnings? Pedro