From nobody Fri Apr 3 08:17:54 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 CC41AECAAD8 for ; Wed, 14 Sep 2022 03:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbiINDie (ORCPT ); Tue, 13 Sep 2022 23:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiINDi3 (ORCPT ); Tue, 13 Sep 2022 23:38:29 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8A385FAFC for ; Tue, 13 Sep 2022 20:38:28 -0700 (PDT) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MS5YZ2g1Szcn56; Wed, 14 Sep 2022 11:34:42 +0800 (CST) Received: from dggpeml500010.china.huawei.com (7.185.36.155) by dggpeml500022.china.huawei.com (7.185.36.66) 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:38: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; Wed, 14 Sep 2022 11:38:27 +0800 From: Lin Yujun To: , , , , CC: , Subject: [PATCH -next] [ARM] am300epd: Release platform device in case of platform_device_add_data() fails Date: Wed, 14 Sep 2022 11:34:55 +0800 Message-ID: <20220914033455.98964-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: dggems702-chm.china.huawei.com (10.3.19.179) 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" The platform device need to be released when platform_device_add_data() fails. Use platform_device_put() to release 'pdev' in error path. Fixes: 4ce255c1420d ("[ARM] 5354/1: mach-pxa: add AM300 platform driver v3") Signed-off-by: Lin Yujun --- arch/arm/mach-pxa/am300epd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-pxa/am300epd.c b/arch/arm/mach-pxa/am300epd.c index 4b55bc89db8f..f8542b6aa9b7 100644 --- a/arch/arm/mach-pxa/am300epd.c +++ b/arch/arm/mach-pxa/am300epd.c @@ -275,11 +275,14 @@ int __init am300_init(void) return -ENOMEM; =20 /* the am300_board that will be seen by broadsheetfb is a copy */ - platform_device_add_data(am300_device, &am300_board, + ret =3D platform_device_add_data(am300_device, &am300_board, sizeof(am300_board)); + if (ret) { + platform_device_put(am300_device); + return ret; + } =20 ret =3D platform_device_add(am300_device); - if (ret) { platform_device_put(am300_device); return ret; --=20 2.17.1