Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4180432rwl; Mon, 3 Apr 2023 00:44:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YmDP3lv/je5FTyD323hEufaHHe2HFFRduRUYmgG9iB70A1iocbXBxGtQDasjiLMHu5zCse X-Received: by 2002:a17:906:9717:b0:930:57e5:d9a8 with SMTP id k23-20020a170906971700b0093057e5d9a8mr33036001ejx.68.1680507846408; Mon, 03 Apr 2023 00:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680507846; cv=none; d=google.com; s=arc-20160816; b=r/o83NlmOywP+xdFr9hbAfSb+i6pQmu7Jm+/dy3xW27lhyxbkiuysWS0so0Qa+uerP dgS2JxBEFyyfsuQTzU1RRymyHL6tgzAPOgDgLlm9m4hUnfBD42FYCVNOdsX+QPrd8+Z6 4IojdfMx40CBXGd3HcAhJdqqM2zIUTbnnPUpnLh2zzuuka/YXH7CyRSg8LgPHvUGj7yx vbz4SAgOMasb0ibDrGditG6IOOciAT96ONA9J8T/jB+2klpAwAaBWvKD074nLBy6WeP0 ZYO5OoPlYJvtv12Q89sw7gqubgDqgEzwp1nVD2BEcXhhN/EcVOhKpKOpN7T6uylo8nPd yCDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iljKYoYT2ePjzYz9iCguWo2fputM/ySIgsJEj1WtGBA=; b=HSvoaRKJxlhtij3eA3SiwYp+H/jch+d2jvYWG4hidFsBo8MadzIIKJKglqzMJz5lBX EdQ1q7xPQuJkYd+GfvNF4sajL6Ef5gDk/7LDsZnv3F7MRhkP5fgqRooSfLIHK8TW9VEa 0UIffDJ05QkuwQZOeKQPvFaxMpNLdtj/790g8uZCJ6PppGePIyL/4Rvr0B5BSy9Z3xVF xUFQ7dUvVdtyb9UYRV24WgHhpYer4dYVJgjnkrV5P+ON7KDyHk4r8QnauK3XHGMt7dqK fZXScrGZlzj7WWVjVpicCXbK5YB2cmViouFEMQD+Ms5jbigSWOdbHY+CDwcGiQygT6ut SLMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JwCBZ1C7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a1709060cd200b009333cf9aaf0si6471432ejh.537.2023.04.03.00.43.41; Mon, 03 Apr 2023 00:44:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JwCBZ1C7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbjDCHeg (ORCPT + 99 others); Mon, 3 Apr 2023 03:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbjDCHef (ORCPT ); Mon, 3 Apr 2023 03:34:35 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9007AB759; Mon, 3 Apr 2023 00:34:33 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id x3so113334710edb.10; Mon, 03 Apr 2023 00:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507272; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=iljKYoYT2ePjzYz9iCguWo2fputM/ySIgsJEj1WtGBA=; b=JwCBZ1C71BCvlADWk9aoGIeWpoywTmjsQBZUzDxTDT/EM3mDHzeEvxJ33aIVs1c+lv a3niccIrb9X480qtVHcGOCGKE84PZPd0OO7vN3qHO21fpyn6xV5M7vWXjIGlwklA/o8B kKNhuMxSN6Pv9se7VcoT3n5MjgrvwNbbv+2gGE6HWk7Up6ddPoTK1ZCeCK/kNB5adkbv 8+Ry7zBOByXzq+LLbo0Ui3iYiwmBzpYYn5Rx6GK4xCOVAVf7EuHinsfBX76fkhzEqePx A1jpvuzKC966WbgaGXxMDCPq6aNRWAKCjrDvC3UdQaFWJA//l7Z6yvs2tF5yAkKeivyo Hstg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507272; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iljKYoYT2ePjzYz9iCguWo2fputM/ySIgsJEj1WtGBA=; b=e5V6bUQ/3Hee16nsvtugjv+z7jt5qhRMz1nxnUO7qY2fZyWIzcJxLBV1b1hYlDne8O X5w5VvXvE6+Fz7g7P1YlaALNu+yXdbNkkVpr1M22Dt2IQfHImr7hKxlkx0ffFoKRRWND eSt+KzJVzc8QKWwHBf7NnFrY2n6fUz83TNyRx3jWCOkHF+MmcCvUWxYu6+eJP6nmNlDS LK9b64B0k+V9NGeoL/76CFQTz94ykvhOrBGyAtYyLmRQ87dlzpaUHrvSWn7nBVS8948H mIsR2keL+FoJS/Fp2ylR43rhQSCAq98YNJpoHmGQEHTmJ6HftS1606fFDY2nOzXcTBO4 q3JA== X-Gm-Message-State: AAQBX9fMw54k++MQsd1GQFXi5HOnuzvGoBSwvlmXCd0Qtjug18EkKxA3 V7Jy0iaAR0NcUHs8w6vOtx4= X-Received: by 2002:a17:906:4f0b:b0:931:59f:d42 with SMTP id t11-20020a1709064f0b00b00931059f0d42mr36891514eju.29.1680507271690; Mon, 03 Apr 2023 00:34:31 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id cw16-20020a170906c79000b0093dce4e6257sm4095134ejb.201.2023.04.03.00.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:34:30 -0700 (PDT) Date: Mon, 3 Apr 2023 10:34:27 +0300 From: Dan Carpenter To: Geert Uytterhoeven Cc: Li Yang , Magnus Damm , Lad Prabhakar , Biju Das , linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] soc: renesas: renesas-soc: release 'chipid' from ioremap() Message-ID: <302d88ca-7d28-4450-8e60-d0bb40f4174d@kili.mountain> References: <20230331095545.31823-1-lidaxian@hust.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 03, 2023 at 09:12:55AM +0200, Geert Uytterhoeven wrote: > Hi Dan, > > On Mon, Apr 3, 2023 at 6:29 AM Dan Carpenter wrote: > > On Fri, Mar 31, 2023 at 02:13:10PM +0200, Geert Uytterhoeven wrote: > > > On Fri, Mar 31, 2023 at 12:14 PM Li Yang wrote: > > > > Smatch reports: > > > > > > > > drivers/soc/renesas/renesas-soc.c:536 renesas_soc_init() warn: > > > > 'chipid' from ioremap() not released on lines: 475. > > > > > > > > If soc_dev_atrr allocation is failed, function renesas_soc_init() > > > > will return without releasing 'chipid' from ioremap(). > > > > > > > > Fix this by adding function iounmap(). > > > > > > > > Fixes: cb5508e47e60 ("soc: renesas: Add support for reading product revision for RZ/G2L family") > > > > Signed-off-by: Li Yang > > > > Reviewed-by: Dan Carpenter > > > > > > Thanks for your patch! > > > > > > > --- a/drivers/soc/renesas/renesas-soc.c > > > > +++ b/drivers/soc/renesas/renesas-soc.c > > > > @@ -471,8 +471,11 @@ static int __init renesas_soc_init(void) > > > > } > > > > > > > > soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); > > > > - if (!soc_dev_attr) > > > > + if (!soc_dev_attr) { > > > > + if (chipid) > > > > + iounmap(chipid); > > > > > > We don't really care, as the system is dead at this point anyway. > > > > Why even have the check for NULL then? The kzalloc() is small enough > > Because else someone will submit a patch to add that check? ;-) > > > to the point where it litterally cannot fail. > > I still don't understand how it can be guaranteed that small allocations > never fail... "while (1) kmalloc(16, GFP_KERNEL);" > I read an lwn article on it and I think I once looked it up to try figure out how small the definition of "small" was and it was surprisingly large... But I have no idea. I think maybe small atomic allocations can fail and GFP_KERNEL allocations sleep forever? (These guesses are worthless). > Perhaps we need a different mechanism to annotate error handling code > that cannot ever happen in a real product, so it can be thrown away by > the compiler, while still pleasing the static checkers? All these > checks and error handling code do affect kernel size. There are > Linux products running on SoCs with 8 MiB of internal SRAM. People sometimes call BUG_ON(!soc_dev_attr). It's sort of rare these days. It would be easy to make a function which silences Smatch... __system_is_dead(); regards, dan carpenter