net: dsa: tag_ocelot_8021q: add support for PTP timestamping
Hello Vladimir Oltean,
The patch 0a6f17c6ae21: "net: dsa: tag_ocelot_8021q: add support for PTP timestamping" from Feb 14, 2021, leads to the following static checker warning:
drivers/net/dsa/ocelot/felix.c:1331 felix_check_xtr_pkt()
error: uninitialized symbol 'err'.
drivers/net/ethernet/mscc/ocelot_vsc7514.c:554 ocelot_xtr_irq_handler()
error: uninitialized symbol 'err'
drivers/net/dsa/ocelot/felix.c
1288 static bool felix_check_xtr_pkt(struct ocelot *ocelot, unsigned int ptp_type) 1289 {
1290 struct felix *felix = ocelot_to_felix(ocelot);
1291 int err, grp = 0;
1292
1293 if (felix->tag_proto != DSA_TAG_PROTO_OCELOT_8021Q)
1294 return false;
1295
1296 if (!felix->info->quirk_no_xtr_irq)
1297 return false;
1298
1299 if (ptp_type == PTP_CLASS_NONE)
1300 return false;
1301
1302 while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp)) {
What about if we don't ever enter this loop?
1303 struct sk_buff *skb;
1304 unsigned int type;
1305
1306 err = ocelot_xtr_poll_frame(ocelot, grp, &skb);
1307 if (err)
1308 goto out;
1309
1310 /* We trap to the CPU port module all PTP frames, but
1311 * felix_rxtstamp() only gets called for event frames.
1312 * So we need to avoid sending duplicate general
1313 * message frames by running a second BPF classifier
1314 * here and dropping those.
1315 */
1316 __skb_push(skb, ETH_HLEN);
1317
1318 type = ptp_classify_raw(skb);
1319
1320 __skb_pull(skb, ETH_HLEN);
1321
1322 if (type == PTP_CLASS_NONE) {
1323 kfree_skb(skb);
1324 continue;
1325 }
1326
1327 netif_rx(skb);
1328 }
1329
1330 out:
1331 if (err < 0)
1332 ocelot_drain_cpu_queue(ocelot, 0);
1333 regards,
dan carpenter
Hi Dan,
Quoted 1 line · Dan Carpenter
What about if we don't ever enter this loop?
This is a real bug, thanks for reporting. It would be good if you could initialize err with zero.