Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1239453pxb; Fri, 21 Jan 2022 13:06:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzF2gvRbt66eOzUAqnQu4CLo67LyWUqLCp346xw48pu8xePrUhP2lcHt9UbrQ4LX33UN0/Q X-Received: by 2002:a17:90b:797:: with SMTP id l23mr2471753pjz.30.1642799189573; Fri, 21 Jan 2022 13:06:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642799189; cv=none; d=google.com; s=arc-20160816; b=B6kFWHaRQ8R1vTJ3bOfs7Mmdq0CspAiBqIQrwQYJBFpF+rkNFOiRPPebK4WzbsW2Sc Uh0ADbvK3h0dT5TxdoYJaz4tYKj+M6rPcPpDlvc0xs9z/RUyWvJRgJVPBYZQFWVp0Qmn nkroM3tGPyupLJLO4Vw5qgfFLPwhWxKWySSkh4nz1s7/zoHVq1zZyyv0323P7AFqNS3j HTXG23j7rjUxhZzdxiQsVsLxjWaMk0ffaGytFGPw+twyK+BKOOITQ3ev5TFjaq9lmKvk nIrf5v99sA2no8MwMdzXu8FBvqoU5Eah1Tu9xvcLvfZjlcdEqrHjwzEencwr+HPdgLtR ps7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=uTOlMm7dzu0jbyQo1QeEz3Myp4L7DwIijJStwI9RjIo=; b=SwKVoxYMJM4QTy+gcHFSLsUPp5p4m0Aikz7o5yfSO/Ct4zYJ1ARnoJREE+zLprBS47 9GNtjTE0aAIEbwJjgoaMJVFyN7ZZaY3GM3BPr7PTJcBcj7q8LtybnRueFq4IrV/7Tu0m sU+F7IraFItbxUeAO813HgBv3V+F/ResEUBZScTndAb9wUwjHWeJJB0yrDIJ99TM+fEB 7U6/yghYnI7S6RCSMPGXrNESx06UC31pfNO8aiJg6vzVKXMV79FGkqsQOLrJKs6rUi0j iqQhGUvYiBt0XzdBiAN0wfGLaLQejUHPUp/64eKUeNOux7SE92onJ+fao+SjIp6/+cgg seOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si6404681plk.379.2022.01.21.13.06.20; Fri, 21 Jan 2022 13:06:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237051AbiATGIs (ORCPT + 70 others); Thu, 20 Jan 2022 01:08:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231792AbiATGIs (ORCPT ); Thu, 20 Jan 2022 01:08:48 -0500 Received: from mail.marcansoft.com (marcansoft.com [IPv6:2a01:298:fe:f::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A263C061574; Wed, 19 Jan 2022 22:08:47 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 9F2054246A; Thu, 20 Jan 2022 06:08:38 +0000 (UTC) Subject: Re: [PATCH v3 2/9] brcmfmac: firmware: Allocate space for default boardrev in nvram To: Andy Shevchenko Cc: Kalle Valo , "David S. Miller" , Jakub Kicinski , Rob Herring , "Rafael J. Wysocki" , Len Brown , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-hsien Lin , Wright Feng , Dmitry Osipenko , Sven Peter , Alyssa Rosenzweig , Mark Kettenis , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Pieter-Paul Giesberts , Linus Walleij , Hans de Goede , "John W. Linville" , "brian m. carlson" , "open list:TI WILINK WIRELES..." , netdev , devicetree , Linux Kernel Mailing List , ACPI Devel Maling List , "open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER" , SHA-cyfmac-dev-list@infineon.com References: <20220117142919.207370-1-marcan@marcan.st> <20220117142919.207370-3-marcan@marcan.st> From: Hector Martin Message-ID: Date: Thu, 20 Jan 2022 15:08:36 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: es-ES Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 20/01/2022 06.35, Andy Shevchenko wrote: > On Mon, Jan 17, 2022 at 4:30 PM Hector Martin wrote: >> >> If boardrev is missing from the NVRAM we add a default one, but this >> might need more space in the output buffer than was allocated. Ensure >> we have enough padding for this in the buffer. > > Do you know this ahead (before allocation happens)? > If yes, the size change should happen conditionally. > > Alternatively, krealloc() may be used. We don't know if we will have to add a boardrev until we find it's missing. The buffer is already oversized anyway, as its size is computed based on the input NVRAM size, while comments and such will be removed. This is just increasing the existing worst-case allocation to properly account for the true worst-case case. I don't think trying to keep the buffer perfectly sized buys us anything here, since it will be freed after download anyway. There's no point in saving a few bytes of memory in the interim. -- Hector Martin (marcan@marcan.st) Public Key: https://mrcn.st/pub