All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] qed: fix the allocation of the chains with an external PBL
@ 2020-07-27 11:51 Alexander Lobakin
  2020-07-27 19:18 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lobakin @ 2020-07-27 11:51 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Alexander Lobakin, Igor Russkikh, Michal Kalderon, Ariel Elior,
	Denis Bolotin, GR-everest-linux-l2, netdev, linux-kernel,
	Dan Carpenter

Dan reports static checker warning:

"The patch 9b6ee3cf95d3: "qed: sanitize PBL chains allocation" from Jul
23, 2020, leads to the following static checker warning:

	drivers/net/ethernet/qlogic/qed/qed_chain.c:299 qed_chain_alloc_pbl()
	error: uninitialized symbol 'pbl_virt'.

drivers/net/ethernet/qlogic/qed/qed_chain.c
   249  static int qed_chain_alloc_pbl(struct qed_dev *cdev, struct qed_chain *chain)
   250  {
   251          struct device *dev = &cdev->pdev->dev;
   252          struct addr_tbl_entry *addr_tbl;
   253          dma_addr_t phys, pbl_phys;
   254          __le64 *pbl_virt;
                ^^^^^^^^^^^^^^^^
[...]
   271          if (chain->b_external_pbl)
   272                  goto alloc_pages;
                        ^^^^^^^^^^^^^^^^ uninitialized
[...]
   298                  /* Fill the PBL table with the physical address of the page */
   299                  pbl_virt[i] = cpu_to_le64(phys);
                        ^^^^^^^^^^^
[...]
"

This issue was introduced with commit c3a321b06a80 ("qed: simplify
initialization of the chains with an external PBL"), when
chain->pbl_sp.table_virt initialization was moved up to
qed_chain_init_params().
Fix it by initializing pbl_virt with an already filled chain struct field.

Fixes: c3a321b06a80 ("qed: simplify initialization of the chains with an external PBL")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexander Lobakin <alobakin@marvell.com>
---
 drivers/net/ethernet/qlogic/qed/qed_chain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_chain.c b/drivers/net/ethernet/qlogic/qed/qed_chain.c
index f8efd36d66e0..b83d17b14e85 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_chain.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_chain.c
@@ -268,8 +268,10 @@ static int qed_chain_alloc_pbl(struct qed_dev *cdev, struct qed_chain *chain)
 
 	chain->pbl.pp_addr_tbl = addr_tbl;
 
-	if (chain->b_external_pbl)
+	if (chain->b_external_pbl) {
+		pbl_virt = chain->pbl_sp.table_virt;
 		goto alloc_pages;
+	}
 
 	size = array_size(page_cnt, sizeof(*pbl_virt));
 	if (unlikely(size == SIZE_MAX))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] qed: fix the allocation of the chains with an external PBL
  2020-07-27 11:51 [PATCH net-next] qed: fix the allocation of the chains with an external PBL Alexander Lobakin
@ 2020-07-27 19:18 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-07-27 19:18 UTC (permalink / raw)
  To: alobakin
  Cc: kuba, irusskikh, michal.kalderon, aelior, denis.bolotin,
	GR-everest-linux-l2, netdev, linux-kernel, dan.carpenter

From: Alexander Lobakin <alobakin@marvell.com>
Date: Mon, 27 Jul 2020 14:51:33 +0300

> Dan reports static checker warning:
> 
> "The patch 9b6ee3cf95d3: "qed: sanitize PBL chains allocation" from Jul
> 23, 2020, leads to the following static checker warning:
> 
> 	drivers/net/ethernet/qlogic/qed/qed_chain.c:299 qed_chain_alloc_pbl()
> 	error: uninitialized symbol 'pbl_virt'.
> 
> drivers/net/ethernet/qlogic/qed/qed_chain.c
>    249  static int qed_chain_alloc_pbl(struct qed_dev *cdev, struct qed_chain *chain)
>    250  {
>    251          struct device *dev = &cdev->pdev->dev;
>    252          struct addr_tbl_entry *addr_tbl;
>    253          dma_addr_t phys, pbl_phys;
>    254          __le64 *pbl_virt;
>                 ^^^^^^^^^^^^^^^^
> [...]
>    271          if (chain->b_external_pbl)
>    272                  goto alloc_pages;
>                         ^^^^^^^^^^^^^^^^ uninitialized
> [...]
>    298                  /* Fill the PBL table with the physical address of the page */
>    299                  pbl_virt[i] = cpu_to_le64(phys);
>                         ^^^^^^^^^^^
> [...]
> "
> 
> This issue was introduced with commit c3a321b06a80 ("qed: simplify
> initialization of the chains with an external PBL"), when
> chain->pbl_sp.table_virt initialization was moved up to
> qed_chain_init_params().
> Fix it by initializing pbl_virt with an already filled chain struct field.
> 
> Fixes: c3a321b06a80 ("qed: simplify initialization of the chains with an external PBL")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Alexander Lobakin <alobakin@marvell.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-27 19:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 11:51 [PATCH net-next] qed: fix the allocation of the chains with an external PBL Alexander Lobakin
2020-07-27 19:18 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.