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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 ACE91C4743F for ; Mon, 7 Jun 2021 07:11:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D9F96120F for ; Mon, 7 Jun 2021 07:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230225AbhFGHMy (ORCPT ); Mon, 7 Jun 2021 03:12:54 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:4334 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhFGHMw (ORCPT ); Mon, 7 Jun 2021 03:12:52 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Fz4Ck5rsbz1BJmT; Mon, 7 Jun 2021 15:06:10 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 7 Jun 2021 15:10:59 +0800 Received: from [127.0.0.1] (10.174.177.72) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 7 Jun 2021 15:10:59 +0800 Subject: Re: [PATCH 1/1] lib: devres: Add error information printing for __devm_ioremap_resource() To: Geert Uytterhoeven CC: Greg Kroah-Hartman , linux-kernel , Vladimir Oltean References: <20210428063203.691-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: Date: Mon, 7 Jun 2021 15:10:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.72] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/17 15:04, Geert Uytterhoeven wrote: > Hi Zhen, > > On Wed, Apr 28, 2021 at 8:33 AM Zhen Lei wrote: >> Ensure that all error handling branches print error information. In this >> way, when this function fails, the upper-layer functions can directly >> return an error code without missing debugging information. Otherwise, >> the error message will be printed redundantly or missing. >> >> Fixes: 35bd8c07db2c ("devres: keep both device name and resource name in pretty name") >> Signed-off-by: Zhen Lei > > Thanks for your patch, which is now commit 5c3e241f5246445d ("lib: > devres: Add error information printing for __devm_ioremap_resource()") > in driver-core-next. > >> --- a/lib/devres.c >> +++ b/lib/devres.c >> @@ -157,8 +157,10 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, >> dev_name(dev), res->name); >> else >> pretty_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); >> - if (!pretty_name) >> + if (!pretty_name) { >> + dev_err(dev, "can't generate pretty name for resource %pR\n", res); > > If the above fails, it is due to a memory allocation failure, and the > memory allocation core will have already printed an error message. > So there is no need to print a second message. > Hence IMHO this commit should be reverted. If the memory allocation fails, only the 'size' is printed, but the start address of the 'res' is not printed. So the printing here is not repeated. The start address is the more critical help information. > >> return IOMEM_ERR_PTR(-ENOMEM); >> + } >> >> if (!devm_request_mem_region(dev, res->start, size, pretty_name)) { >> dev_err(dev, "can't request region for resource %pR\n", res); > > Gr{oetje,eeting}s, > > Geert >