]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bnxt_en: Fix a possible memory leak in bnxt_ptp_init
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Tue, 4 Nov 2025 00:56:56 +0000 (16:56 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:43 +0000 (15:37 -0500)
[ Upstream commit deb8eb39164382f1f67ef8e8af9176baf5e10f2d ]

In bnxt_ptp_init(), when ptp_clock_register() fails, the driver is
not freeing the memory allocated for ptp_info->pin_config.  Fix it
to unconditionally free ptp_info->pin_config in bnxt_ptp_free().

Fixes: caf3eedbcd8d ("bnxt_en: 1PPS support for 5750X family chips")
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20251104005700.542174-3-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

index ca660e6d28a4c2b6668743ac832d80071ff40b97..8f2faff044591c98b9c72bc1d88f3f1a90fb868a 100644 (file)
@@ -1054,9 +1054,9 @@ static void bnxt_ptp_free(struct bnxt *bp)
        if (ptp->ptp_clock) {
                ptp_clock_unregister(ptp->ptp_clock);
                ptp->ptp_clock = NULL;
-               kfree(ptp->ptp_info.pin_config);
-               ptp->ptp_info.pin_config = NULL;
        }
+       kfree(ptp->ptp_info.pin_config);
+       ptp->ptp_info.pin_config = NULL;
 }
 
 int bnxt_ptp_init(struct bnxt *bp)