octeontx2-af: Fix klockwork issues in AF driver
v2 cover octeontx2-af: Fix klockwork issues in AF driver
This patchset fixes minor klockwork issues in multiple files in AF driver
Patch #1: octeontx2-af: Fix klockwork issue in cgx.c
Patch #2: octeontx2-af: Fix klockwork issues in mcs_rvu_if.c
Patch #3: octeontx2-af: Fixes klockwork issues in ptp.c
Patch #4: octeontx2-af: Fixes klockwork issues in rvu_cpt.c
Patch #5: octeontx2-af: Fixes klockwork issues in rvu_debugfs.c
Patch #6: octeontx2-af: Fix klockwork issue in rvu_nix.c
Patch #7: octeontx2-af: Fix klockwork issue in rvu_npc.c
Suman Ghosh (7):
octeontx2-af: Fix klockwork issue in cgx.c
octeontx2-af: Fix klockwork issue in mcs_rvu_if.c
octeontx2-af: Fixes klockwork issues in ptp.c
octeontx2-af: Fixes klockwork issues in rvu_cpt.c
octeontx2-af: Fixes klockwork issues in rvu_debugfs.c
octeontx2-af: Fix klockwork issue in rvu_nix.c
octeontx2-af: Fix klockwork issue in rvu_npc.c
v2 changes:
- Updated description for all the patchsets to address comment from Markus
- Removed variable initialization from cgx.c(patch #1) to avoid fix of different klockwork issues
drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 7 +++++++ .../net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 6 ++++-- drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 11 ++++++++++- drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 8 +++++++- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 +- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1 + 7 files changed, 31 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/7 octeontx2-af: Fix klockwork issue in cgx.c
Variable "cgx_dev" and "lmac" was getting accessed without NULL checks which can lead to pointer exception in some erroneous scenarios. This patch fixes the same by adding the required NULL checks.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +7 -0
@@ -465,6 +465,13 @@ u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id)u64 cfg;int id; +if (!cgx_dev) +return 0 ; + + lmac =lmac_pdata (lmac_id, cgx_dev); +if (!lmac) +return 0 ; + mac_ops = cgx_dev->mac_ops; id =get_sequence_id_of_lmac (cgx_dev, lmac_id);
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerRe: [net PATCH v2 1/7] octeontx2-af: Fix klockwork issue in cgx.c
Quoted 3 lines · On Tue, 25 Jun 2024 23:03:43 +0530 Suman Ghosh wrote:
Variable "
cgx_dev" and "lmac" was getting accessed without NULL checks which can lead to pointer exception in some erroneous scenarios. This patch fixes the same by adding the required NULL checks.
Please remove the name of the tool from the subject, too.
You can add something like:
Addresses klockwork warning ${the warning generated or such}
at the end of the commit message.
If there's a path which can lead to a crash please describe it. If there's no real issue, it's not a fix (no Fixes and net-next).
But really, we tend to avoid addressing issues just to please overzealous static code analysis tools. And we advise against defensive programming, so please make sure the patches actually make sense. I don't think patch 6 does, picking a random one to check..
PATCH v2 2/7 octeontx2-af: Fix klockwork issues in mcs_rvu_if.c
In reply to Suman GhoshThese are not real issues but sanity checks.
--- drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +4 -2
@@ -681,7 +681,7 @@ int rvu_mbox_handler_mcs_alloc_resources(struct rvu *rvu,u16 pcifunc = req->hdr.pcifunc;struct mcs_rsrc_map *map;struct mcs *mcs; -int rsrc_id, i; +int rsrc_id = -EINVAL , i;if (req->mcs_id >= rvu->mcs_blk_cnt)return MCS_AF_ERR_INVALID_MCSID ;
@@ -742,6 +742,8 @@ int rvu_mbox_handler_mcs_alloc_resources(struct rvu *rvu, rsp->rsrc_cnt++; }break ; +default : + goto exit; } rsp->rsrc_type = req->rsrc_type;
@@ -854,7 +856,7 @@ int rvu_mbox_handler_mcs_ctrl_pkt_rule_write(struct rvu *rvu,static void rvu_mcs_set_lmac_bmap (struct rvu *rvu) {struct mcs *mcs =mcs_get_pdata (0 ); -unsigned long lmac_bmap; +unsigned long lmac_bmap =0 ;int cgx, lmac, port;for (port =0 ; port < mcs->hw->lmac_cnt; port++) {
Signature · 1 line
2.25.1
Re: [net PATCH 2/7] octeontx2-af: Fix klockwork issues in mcs_rvu_if.c
Quoted 1 line
These are not real issues but sanity checks.
…
* Did the mentioned source code analysis tool present more detailed reports and special development views?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n45
* You accidentally overlooked to specify a corresponding version identification in the message subject, didn't you?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n668
Regards,
Markus
PATCH v2 2/7 octeontx2-af: Fix klockwork issue in mcs_rvu_if.c
In reply to Suman GhoshThere was a missing "default" condtion in a mailbox switch case, which can lead to wrong response message to the caller. This patch fixes the same by adding gracefull exit for a "default" switch case scenario.
--- drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +4 -2
@@ -681,7 +681,7 @@ int rvu_mbox_handler_mcs_alloc_resources(struct rvu *rvu,u16 pcifunc = req->hdr.pcifunc;struct mcs_rsrc_map *map;struct mcs *mcs; -int rsrc_id, i; +int rsrc_id = -EINVAL , i;if (req->mcs_id >= rvu->mcs_blk_cnt)return MCS_AF_ERR_INVALID_MCSID ;
@@ -742,6 +742,8 @@ int rvu_mbox_handler_mcs_alloc_resources(struct rvu *rvu, rsp->rsrc_cnt++; }break ; +default : + goto exit; } rsp->rsrc_type = req->rsrc_type;
@@ -854,7 +856,7 @@ int rvu_mbox_handler_mcs_ctrl_pkt_rule_write(struct rvu *rvu,static void rvu_mcs_set_lmac_bmap (struct rvu *rvu) {struct mcs *mcs =mcs_get_pdata (0 ); -unsigned long lmac_bmap; +unsigned long lmac_bmap =0 ;int cgx, lmac, port;for (port =0 ; port < mcs->hw->lmac_cnt; port++) {
Signature · 1 line
2.25.1
PATCH v2 3/7 octeontx2-af: Fixes klockwork issues in ptp.c
In reply to Suman GhoshSome variable was getting accessed without NULL checks which can lead to pointer exception in some erroneous scenarios. This patch fixes the same by adding the required NULL checks.
--- drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/ptp.c +10 -1
@@ -517,6 +517,7 @@ static int ptp_pps_on(struct ptp *ptp, int on, u64 period)static int ptp_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { +void __iomem *const *base;struct ptp *ptp;int err;
@@ -536,7 +537,15 @@ static int ptp_probe(struct pci_dev *pdev,if (err) goto error_free; - ptp->reg_base =pcim_iomap_table (pdev)[PCI_PTP_BAR_NO ]; + base =pcim_iomap_table (pdev); +if (!base) + goto error_free; + + ptp->reg_base = base[PCI_PTP_BAR_NO ]; +if (!ptp->reg_base) { + err = -ENODEV ; + goto error_free; + }pci_set_drvdata (pdev, ptp);if (!first_ptp_block)
Signature · 1 line
2.25.1
PATCH v2 4/7 octeontx2-af: Fixes klockwork issues in rvu_cpt.c
In reply to Suman GhoshAdded initialization of a local variable to avoid junk values if it is used before set.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c +1 -1
@@ -43,7 +43,7 @@ static irqreturn_t cpt_af_flt_intr_handler(int vec, void *ptr)struct rvu *rvu = block->rvu;int blkaddr = block->addr;u64 reg, val; -int i, eng; +int i, eng =0 ;u8 grp; reg =rvu_read64 (rvu, blkaddr,CPT_AF_FLTX_INT (vec));
Signature · 1 line
2.25.1
PATCH v2 5/7 octeontx2-af: Fixes klockwork issues in rvu_debugfs.c
In reply to Suman GhoshAs part of this fix, fixed sized char array is converted to dynamic sized array to avoid splitting of some debug information.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +7 -1
@@ -518,13 +518,17 @@ RVU_DEBUG_SEQ_FOPS(mcs_rx_secy_stats, mcs_rx_secy_stats_display, NULL);static void rvu_dbg_mcs_init (struct rvu *rvu) { +char *dname =NULL ;struct mcs *mcs; -char dname[10 ];int i;if (!rvu->mcs_blk_cnt)return ; + dname =kmalloc_array (rvu->mcs_blk_cnt,sizeof (char ),GFP_KERNEL ); +if (!dname) +return ; + rvu->rvu_dbg.mcs_root =debugfs_create_dir ("mcs" , rvu->rvu_dbg.root);for (i =0 ; i < rvu->mcs_blk_cnt; i++) {
@@ -568,6 +572,8 @@ static void rvu_dbg_mcs_init(struct rvu *rvu)debugfs_create_file ("port" ,0600 , rvu->rvu_dbg.mcs_tx, mcs, &rvu_dbg_mcs_tx_port_stats_fops); } + +kfree (dname); }#define LMT_MAPTBL_ENTRY_SIZE 16
Signature · 1 line
2.25.1
PATCH v2 6/7 octeontx2-af: Fix klockwork issue in rvu_nix.c
In reply to Suman GhoshAdded initialization of a local variable to avoid junk values if it is used before set.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1 -1
@@ -5375,7 +5375,7 @@ static void nix_inline_ipsec_cfg(struct rvu *rvu, struct nix_inline_ipsec_cfg *r int blkaddr) {u8 cpt_idx, cpt_blkaddr; -u64 val; +u64 val =0 ; cpt_idx = (blkaddr ==BLKADDR_NIX0 ) ?0 :1 ;if (req->enable) {
Signature · 1 line
2.25.1
PATCH v2 7/7 octeontx2-af: Fix klockwork issue in rvu_npc.c
In reply to Suman GhoshSet the pointer value to NULL after freeing to avoid wrong access.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +1 -0
@@ -1765,6 +1765,7 @@ static void npc_load_kpu_profile(struct rvu *rvu) rvu->kpu_prfl_addr =NULL ; }else {kfree (rvu->kpu_fwdata); + rvu->kpu_fwdata =NULL ; } rvu->kpu_fwdata =NULL ; rvu->kpu_fwdata_sz =0 ;
Signature · 1 line
2.25.1
…
Quoted 4 lines
octeontx2-af: Fix klockwork issue in
rvu_npc.cv2 changes:
- Updated description for all the patchsets to address comment from Markus
…
* Why did you not directly respond to the recurring patch review concern about better summary phrases (or message subjects)?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n646
* Would you like to explain any more here which development concern categories were picked up from the mentioned source code analysis tool?
* How much do you care for the grouping of logical changes into consistent patch series?
Regards,
Markus
A message that is not in the archive (sent off-list or not yet received): SJ0PR18MB52166806AA7FB13ED3DC3E39DBD52@SJ0PR18MB5216.namprd18.prod.outlook.com
Quoted 2 lines
Quoted 2 lines
* Why did you not directly respond to the recurring patch review concern about better summary phrases (or message subjects)?
…
Quoted 1 line
[Suman] I thought the “summery phrase” is per patch.
Summaries are obviously important parts for patch subjects.
Quoted 1 line
The cover letter is mentioning the reason for the change
I would like to read an improved overview for your change approach.
Quoted 1 line
and each patch set is adding the summery for the change.
I have got understanding difficulties for such information somehow.
Quoted 1 line
Since it is not some actual ‘fix’ I am not sure what more to add other
It seems that there is a temporary conflict according to expected explanation quality.
Quoted 1 line
than mentioning klockwork fixes.
Source code analysis tools can provide more helpful information. Do I need to remind you for the published software documentation around “C checkers”?
Quoted 2 lines
I am not sure what more can be added for a variable initialization to zero or adding a NULL check.
* Common vulnerability enumeration?
* CERT reference?
Quoted 1 line
Can you suggest some?
* Please take another look at linked information sources.
* Can you get sufficient inspirations from published patches?
Quoted 4 lines
Quoted 2 lines
* Would you like to explain any more here which development concern categories were picked up from the mentioned source code analysis tool?
[Suman] Development concerns are mentioned in individual patch sets.
* Grouping?
* Outlines?
* Taxonomy?
Quoted 5 lines
Quoted 2 lines
* How much do you care for the grouping of logical changes into consistent patch series?
[Suman] I thought about it but then I was not sure
how to add fix tags for a unified patch set.
Why did you not ask before sending another questionable patch series?
Quoted 1 line
Hence went with per file approach.
It can occasionally be helpful for change preparations.
Quoted 1 line
Do you see any problem with the approach?
Obviously, yes.
I hope that you can take several patch review issues better into account finally.
Regards,
Markus
Jakub Kicinski
maintainerQuoted 18 lines · On Tue, 25 Jun 2024 18:34:55 +0000 Suman Ghosh wrote:
* Why did you not directly respond to the recurring patch review concern
about better summary phrases (or message subjects)?
[Suman] I thought the “summery phrase” is per patch. The cover letter is mentioning the reason for the change and each patch set is adding the summery for the change. Since it is not some actual ‘fix’ I am not sure what more to add other than mentioning klockwork fixes. I am not sure what more can be added for a variable initialization to zero or adding a NULL check. Can you suggest some?
* Would you like to explain any more here which development concern categories
were picked up from the mentioned source code analysis tool?
[Suman] Development concerns are mentioned in individual patch sets. Having junk value in the variable if not initialized or accessing a NULL pointer, etc.
Quoted 5 lines
* How much do you care for the grouping of logical changes into
consistent patch series?
[Suman] I thought about it but then I was not sure how to add fix tags for a unified patch set. Hence went with per file approach. Do you see any problem with the approach?
Please configure your MUA to quote correctly, with > characters.