]> git.ipfire.org Git - thirdparty/linux.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)
committerJakub Kicinski <kuba@kernel.org>
Wed, 5 Nov 2025 01:25:19 +0000 (17:25 -0800)
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>
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

index db81cf6d5289b2e637a46001446f6680bc17bdc2..0abaa2bbe3577e085c7f4d7e8c141fce9a807bda 100644 (file)
@@ -1051,9 +1051,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)