Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7414442rwn; Tue, 13 Sep 2022 20:46:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR75ZGGZQAWoLHUPWq7Zb81v/wtHWmBDycFOJxQn2vDTgZr4hB/jfnnq84CmmjiQ9ZOpzTCa X-Received: by 2002:a17:902:7786:b0:178:48c0:a083 with SMTP id o6-20020a170902778600b0017848c0a083mr5803285pll.125.1663127213493; Tue, 13 Sep 2022 20:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663127213; cv=none; d=google.com; s=arc-20160816; b=n6bduePTAhD0YkVN1BA71I0bIuGbH4IMHH1DkeMh+VwEK8nN0I+86NorctKfvlTYZd v5p3gQ1pSVOeGlOB0EGekji3LtyNJjx1LUjV2dsAhEUbgXJFJ1lCxTYVJsJ6ESlYN4r6 ux7SKVag5f7Lm/JDjZdQtmk1ORXw8c01Olcq00kTau1g/mLeo/y8qBsUp1+Mo+G5Q6f9 gTw4zetfzm8MRvU58IAXyRVTrcX4CzF4iZn2WLjIPGGi86sdYYYIvZSLBtkuZHox3x0c axm2fc3gyr6cfzXu0u3mnNgpsGd62uOt9UpwNGQZ2wRlE9bTNKzg5jGJKn7IkyjwuOcq mDRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=cIsUQ0LNrz1JF97iSRgUY3wIMbJXnJVRK/p97uhx/Eg=; b=gY5yo/AOfB/ftsYxBkY6nRUTNKy1XLMryrtzkBzh9GIFiY/O3uKLYs2tJREnvlBts/ A5f883WKCvKPpD2fwdgPYpfF7LTnMZaI33aVzYKgfU0sNTmdVePYPafXqq7iYJDA88kZ cWv3mDV5b6Ajv+CcyCJWlcIdMnT7WySHD0Y2mEQTBiw97dn2y9Yxd50IKL3qRQZmjOrf zf9Z4ex3zhXsN60lxgCNk0THddDwu+eK0pxzxEAxIiqa9WMyb26CKvxPDogQB3OaA484 v3m9Vsdu/OJNX8iEwmWvoIitMyiDmfIWPoQ+D3YK3DfNa7rFZrYC0nKC2Oos/qA5PDL4 BdKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a63610a000000b004386d70cf15si13678762pgb.206.2022.09.13.20.46.41; Tue, 13 Sep 2022 20:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbiINDd5 (ORCPT + 99 others); Tue, 13 Sep 2022 23:33:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiINDdx (ORCPT ); Tue, 13 Sep 2022 23:33:53 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E7075A8B0 for ; Tue, 13 Sep 2022 20:33:52 -0700 (PDT) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MS5VF0xnXzHnsX; Wed, 14 Sep 2022 11:31:49 +0800 (CST) Received: from dggpeml500010.china.huawei.com (7.185.36.155) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 14 Sep 2022 11:33:50 +0800 Received: from huawei.com (10.67.175.33) by dggpeml500010.china.huawei.com (7.185.36.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 14 Sep 2022 11:33:50 +0800 From: Lin Yujun To: , , , , CC: Subject: [PATCH -next] clocksource/drivers/timer-gxp: Add missing error handling in gxp_timer_probe Date: Wed, 14 Sep 2022 11:30:18 +0800 Message-ID: <20220914033018.97484-1-linyujun809@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.33] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500010.china.huawei.com (7.185.36.155) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add platform_device_put() to make sure to free the platform device in the event platform_device_add() fails. Fixes: 5184f4bf151b ("clocksource/drivers/timer-gxp: Add HPE GXP Timer") Signed-off-by: Lin Yujun --- drivers/clocksource/timer-gxp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/timer-gxp.c b/drivers/clocksource/timer-gxp.c index 8b38b3212388..fe4fa8d7b3f1 100644 --- a/drivers/clocksource/timer-gxp.c +++ b/drivers/clocksource/timer-gxp.c @@ -171,6 +171,7 @@ static int gxp_timer_probe(struct platform_device *pdev) { struct platform_device *gxp_watchdog_device; struct device *dev = &pdev->dev; + int ret; if (!gxp_timer) { pr_err("Gxp Timer not initialized, cannot create watchdog"); @@ -187,7 +188,11 @@ static int gxp_timer_probe(struct platform_device *pdev) gxp_watchdog_device->dev.platform_data = gxp_timer->counter; gxp_watchdog_device->dev.parent = dev; - return platform_device_add(gxp_watchdog_device); + ret = platform_device_add(gxp_watchdog_device); + if (ret) + platform_device_put(gxp_watchdog_device); + + return ret; } static const struct of_device_id gxp_timer_of_match[] = { -- 2.17.1