Thread (6 messages) 6 messages, 5 authors, 2025-02-15

Re: [PATCH] net/mlx4_core: Avoid impossible mlx4_db_alloc() order value

flat view

From: Paolo Abeni <pabeni@redhat.com>
Date: 2025-02-13 10:13:06
Also in: linux-hardening, linux-rdma, lkml

On 2/13/25 1:10 AM, Justin Stitt wrote:
On Tue, Feb 11, 2025 at 6:22 AM Tariq Toukan [off-list ref] wrote:
quoted
On 11/02/2025 2:01, Justin Stitt wrote:
quoted
quoted
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c
index b330020dc0d6..f2bded847e61 100644
--- a/drivers/net/ethernet/mellanox/mlx4/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c
@@ -682,9 +682,9 @@ static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device)
  }

  static int mlx4_alloc_db_from_pgdir(struct mlx4_db_pgdir *pgdir,
-                                struct mlx4_db *db, int order)
+                                struct mlx4_db *db, unsigned int order)
  {
-    int o;
+    unsigned int o;
     int i;

     for (o = order; o <= 1; ++o) {
   ^ Knowing now that @order can only be 0 or 1 can this for loop (and
   goto) be dropped entirely?
Maybe I'm missing something...
Can you please explain why you think this can be dropped?
I meant "rewritten to use two if statements" instead of "dropped". I
think "replaced" or "refactored" was the word I wanted.
IMHO that would be a significant uglification, not worthy to address an
issue that could be solved with the patch proposed here.

@Tariq: are you ok with this patch?

Thanks,

Paolo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help