From nobody Fri Apr 3 06:45:38 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 39DE0ECAAD3 for ; Thu, 15 Sep 2022 01:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiIOBgn (ORCPT ); Wed, 14 Sep 2022 21:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiIOBgl (ORCPT ); Wed, 14 Sep 2022 21:36:41 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF8259264; Wed, 14 Sep 2022 18:36:40 -0700 (PDT) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MSfnZ3xh9zNmDt; Thu, 15 Sep 2022 09:32:02 +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 09:36:38 +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 09:36:38 +0800 From: Lin Yujun To: , , , , , , CC: , , , Subject: [PATCH -next v2] rtc: stmp3xxx: Add failure handling for stmp3xxx_wdt_register() Date: Thu, 15 Sep 2022 09:33:04 +0800 Message-ID: <20220915013304.213917-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 | 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_devic= e *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); } =20 if (rc) --=20 2.17.1