From nobody Fri Apr 3 08:17:50 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF76ECAAD3 for ; Wed, 14 Sep 2022 03:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229697AbiINDZj (ORCPT ); Tue, 13 Sep 2022 23:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbiINDZg (ORCPT ); Tue, 13 Sep 2022 23:25:36 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7584B20BD8; Tue, 13 Sep 2022 20:25:35 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_devi= ce *rtc_pdev) wdt_pdev->dev.parent =3D &rtc_pdev->dev; wdt_pdev->dev.platform_data =3D &wdt_pdata; rc =3D 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"); } =20 if (rc) --=20 2.17.1