[lkml]   [2019]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 4.19 032/113] qede: fix write to freed pointer error and double free of ptp
    [ Upstream commit 1dc2b3d65523780ed1972d446c76e62e13f3e8f5 ]

    The err2 error return path calls qede_ptp_disable that cleans up
    on an error and frees ptp. After this, the free'd ptp is dereferenced
    when ptp->clock is set to NULL and the code falls-through to error
    path err1 that frees ptp again.

    Fix this by calling qede_ptp_disable and exiting via an error
    return path that does not set ptp->clock or kfree ptp.

    Addresses-Coverity: ("Write to pointer after free")
    Fixes: 035744975aec ("qede: Add support for PTP resource locking.")
    Signed-off-by: Colin Ian King <>
    Signed-off-by: David S. Miller <>
    Signed-off-by: Sasha Levin <>
    drivers/net/ethernet/qlogic/qede/qede_ptp.c | 7 +++----
    1 file changed, 3 insertions(+), 4 deletions(-)

    diff --git a/drivers/net/ethernet/qlogic/qede/qede_ptp.c b/drivers/net/ethernet/qlogic/qede/qede_ptp.c
    index 013ff567283c7..5e574c3b625e5 100644
    --- a/drivers/net/ethernet/qlogic/qede/qede_ptp.c
    +++ b/drivers/net/ethernet/qlogic/qede/qede_ptp.c
    @@ -490,18 +490,17 @@ int qede_ptp_enable(struct qede_dev *edev, bool init_tc)

    ptp->clock = ptp_clock_register(&ptp->clock_info, &edev->pdev->dev);
    if (IS_ERR(ptp->clock)) {
    - rc = -EINVAL;
    DP_ERR(edev, "PTP clock registration failed\n");
    + qede_ptp_disable(edev);
    + rc = -EINVAL;
    goto err2;

    return 0;

    - qede_ptp_disable(edev);
    - ptp->clock = NULL;
    edev->ptp = NULL;

    return rc;

     \ /
      Last update: 2019-05-15 13:53    [W:4.077 / U:0.260 seconds]
    ©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site