From mboxrd@z Thu Jan 1 00:00:00 1970 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 ED83AECAAD3 for ; Wed, 14 Sep 2022 03:26:47 +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=Wug9z9QMr5x1yJ+RO/8RnDrj++jHtyyhHi+coqBSgSE=; b=NKX5icF2XpV0x6 0jDbLUi82X3BOzdS8fRbyHWr4UHv2U+mjLaXFutVI6FRJ3m8BdeS9OMxyCGe5yaoX2zV4Qyro27Vy lhWptDv0tFeL+L/TChRfaUqFmwCH0lYiHsu4sdxqoNjWOy9837hCyYm/mTg2PcEmH8KM3OqgyNp7W wc5hWrKHlo1ZmkDRcVbNCPgc4n71f9+5jvBeMU9AADJDV4C/FZNcuOGG14IwbwtQnZCsBGMWAEinp +6X+8op7JYhrWbPX1gyjFTOKERr8Z9BNzO0qrA5JgFJfxjcZqf0h+R/lESILDhoFFF1M3fyzQPvZE sEiX90OV8Xjw5gwq0Mng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYJ23-005WNY-76; Wed, 14 Sep 2022 03:25:47 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYJ1v-005WHU-Nv for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2022 03:25:44 +0000 Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MS5Hw44wTznV4F; Wed, 14 Sep 2022 11:22:52 +0800 (CST) Received: from dggpeml500010.china.huawei.com (7.185.36.155) by dggpeml500026.china.huawei.com (7.185.36.106) 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:25:32 +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:25:32 +0800 From: Lin Yujun To: , , , , , , CC: , , , Subject: [PATCH -next] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register() Date: Wed, 14 Sep 2022 11:21:59 +0800 Message-ID: <20220914032159.94812-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: dggems706-chm.china.huawei.com (10.3.19.183) 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-20220913_202543_485680_41DE4DE1 X-CRM114-Status: UNSURE ( 9.92 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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. Add dev_err() to report error in case of alloc memory to wdt_pdev fail. Fixes: 1a71fb84fda6 ("rtc: stmp3xxx: add wdt-accessor function") Signed-off-by: Lin Yujun --- drivers/rtc/rtc-stmp3xxx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 40c0f7ed36e0..b2f4b034cdb6 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c @@ -107,6 +107,11 @@ 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); + } else { + dev_err(&rtc_pdev->dev, + "failed to allocate stmp3xxx_rtc_wdt\n"); } if (rc) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel