RDMA/bnxt_re: Fix some error handling paths in bnxt_re_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 1 Nov 2024 16:10:56 +0000 (17:10 +0100)
committerLeon Romanovsky <leon@kernel.org>
Sun, 3 Nov 2024 16:02:02 +0000 (11:02 -0500)
If bnxt_re_add_device() fails, 'en_info' still needs to be freed, as
already done in the .remove() function.

The commit in Fixes incorrectly removed this call, certainly because it
was expecting the .remove() function was called anyway. But if the probe
fails, the remove function is not called.

There is no need to call bnxt_re_remove() as it was done before, kfree()
is enough.

Fixes: a5e099e0c464 ("RDMA/bnxt_re: Fix an error path in bnxt_re_add_device")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/9e48ff955ae55fc39a9eb1eb590d374539eab5ba.1730477345.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/main.c

index 6715c96a3eeef4369d03be9bf3ad2de378ae1643..465cec4a1bd48cd1bc4afd260c63d6e281916421 100644 (file)
@@ -2025,7 +2025,15 @@ static int bnxt_re_probe(struct auxiliary_device *adev,
        auxiliary_set_drvdata(adev, en_info);
 
        rc = bnxt_re_add_device(adev, BNXT_RE_COMPLETE_INIT);
+       if (rc)
+               goto err;
+       mutex_unlock(&bnxt_re_mutex);
+       return 0;
+
+err:
        mutex_unlock(&bnxt_re_mutex);
+       kfree(en_info);
+
        return rc;
 }