From patchwork Thu Sep 15 06:52:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Yujun X-Patchwork-Id: 12976908 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 943A9ECAAA1 for ; Thu, 15 Sep 2022 06:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=cqUsGAwZ8ijlZqssCerJZdFyBp6eXyKt7MpPSfQS/9o=; b=LA9Q3xbb2SAqb3 4Fz9E94Mvi6hqSMYsVsad+TH/XjGgBiVF38/HyHZwkR4ZUl1lLUSlGIIiawlt6jxV/bl5FJq+/L0r jVhdXoHD20hbmG8aTmJhSu+vbGjlIg8egq3rMd9M8J/K/P8pggZU0WGJDEVXdMZY9EiQ/vxnf11xL fQdTLEREyRfXmoDu7CFREN61lOzJCiQmY/keZMBonxl7HW3C/SrFtZmattiAG0j4/IJylXEcsc6MP BwqDBsc1LUUUhxPuhsJ48hdhyqfvyzU5JNYQHkFXF0jf0JvauoGTdVbHJXOPktIKLePE3VYePQgdk GLZQyp+hTx31qZ1caxWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYioL-002KOT-28; Thu, 15 Sep 2022 06:57:21 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYinU-002Jfh-Nf for linux-arm-kernel@lists.infradead.org; Thu, 15 Sep 2022 06:56:30 +0000 Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MSnvX38pGzmVNc; Thu, 15 Sep 2022 14:52:40 +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; Thu, 15 Sep 2022 14:56:27 +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; Thu, 15 Sep 2022 14:56:26 +0800 From: Lin Yujun To: , , , , , , CC: , , , Subject: [PATCH -next v3] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register() Date: Thu, 15 Sep 2022 14:52:53 +0800 Message-ID: <20220915065253.43668-1-linyujun809@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.33] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500010.china.huawei.com (7.185.36.155) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_235628_986114_814FB388 X-CRM114-Status: UNSURE ( 8.52 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use platform_device_put() to free platform device before print error message when platform_device_add() fails to run. Fixes: 1a71fb84fda6 ("rtc: stmp3xxx: add wdt-accessor function") Signed-off-by: Lin Yujun Reviewed-by: Wolfram Sang --- drivers/rtc/rtc-stmp3xxx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 40c0f7ed36e0..aae40d20d086 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c @@ -107,6 +107,8 @@ static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev) wdt_pdev->dev.parent = &rtc_pdev->dev; wdt_pdev->dev.platform_data = &wdt_pdata; rc = platform_device_add(wdt_pdev); + if (rc) + platform_device_put(wdt_pdev); } if (rc)