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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B311C43463 for ; Sat, 19 Sep 2020 01:30:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01818206B6 for ; Sat, 19 Sep 2020 01:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726009AbgISBaz (ORCPT ); Fri, 18 Sep 2020 21:30:55 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:58578 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726327AbgISBaz (ORCPT ); Fri, 18 Sep 2020 21:30:55 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 32022B859BFF745D94BE; Sat, 19 Sep 2020 09:30:53 +0800 (CST) Received: from [10.174.179.91] (10.174.179.91) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Sat, 19 Sep 2020 09:30:51 +0800 Subject: Re: [PATCH -next] m68k/amiga: missing platform_device_unregister() on error in amiga_init_devices() To: Geert Uytterhoeven CC: Stephen Rothwell , Greg Kroah-Hartman , linux-m68k , Linux Kernel Mailing List References: <20200728022746.87612-1-miaoqinglang@huawei.com> From: miaoqinglang Message-ID: <613d3a43-4fb0-48d5-93d6-bf0d8f0bd671@huawei.com> Date: Sat, 19 Sep 2020 09:30:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.91] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-m68k@vger.kernel.org 在 2020/8/26 17:07, Geert Uytterhoeven 写道: > Hi Qinglang, > > On Tue, Jul 28, 2020 at 4:24 AM Qinglang Miao wrote: >> Add the missing platform_device_unregister() before return >> from amiga_init_devices() in the error handling case. >> >> Signed-off-by: Qinglang Miao > > Thanks for your patch! > >> --- a/arch/m68k/amiga/platform.c >> +++ b/arch/m68k/amiga/platform.c >> @@ -188,8 +188,10 @@ static int __init amiga_init_devices(void) >> return PTR_ERR(pdev); >> error = platform_device_add_data(pdev, &a1200_ide_pdata, >> sizeof(a1200_ide_pdata)); > > The only reason why platform_device_add_data() can fail is because the > system ran out of memory. If that's the case this early, the whole > system will fail to work anyway, and it doesn't matter that the IDE > driver will crash later due to missing platform data. > > So I don't think it helps to increase kernel size by adding more error > handling. > Hi Geert, Glad to know your opnions, it sounds resonable to me. Thanks. >> - if (error) >> + if (error) { >> + platform_device_unregister(pdev); >> return error; >> + } >> } >> >> if (AMIGAHW_PRESENT(A4000_IDE)) { >> @@ -199,8 +201,10 @@ static int __init amiga_init_devices(void) >> return PTR_ERR(pdev); >> error = platform_device_add_data(pdev, &a4000_ide_pdata, >> sizeof(a4000_ide_pdata)); >> - if (error) >> + if (error) { >> + platform_device_unregister(pdev); > > Likewise. > >> return error; >> + } > > Gr{oetje,eeting}s, > > Geert >