Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp184042imu; Thu, 8 Nov 2018 06:55:09 -0800 (PST) X-Google-Smtp-Source: AJdET5fmykodTH9NaE7I+xPhdeQAxhuh4+/Cu/P3fUqPrV+7CktcCsO4Cnb0bggyG+H/pIUjE6fH X-Received: by 2002:a63:ba19:: with SMTP id k25mr4017916pgf.194.1541688909902; Thu, 08 Nov 2018 06:55:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541688909; cv=none; d=google.com; s=arc-20160816; b=av89XN5vsM6OlAOARmfLCL0oLDUrnyr3jpoa6wUF6fZgEjeT1m40ce8kbB2mqdT97e b0YQGxicwB0kU+WV6KgiBJzeCsxPTDOoQxwxF9sfDEfVNm/VlHDiuXSQxB+UEXUsd6aP kZjfA0J1CbtKkSOBPmniXqBZY9ZUFCvE0h3EwTV5/jqM7VsYx1IYGWB8XZJGNZ1cDjus dmyYiZHO92umxElrS9f/J73WYqmg9n1kukUXTI5CZfObzhP//h++cX6VgOFhv9xdnRao JxO7EizSLiBsDwogtANkD94Vu1LYKKhC6Nk/SHOtAZnbRJke9FhmWKaMMOdTf9WMKrr/ Kndg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=FwKWBzNrYb2uKF5iyZapMaQGzxBcrJX6V3vsIwlnugw=; b=yxf7DLCzUYU8WlBoX2FIIKX5QyCwb0O/LR6zE4yuRiwhb2c597B+jNZGO0XG5Lq/h5 cseq5g6KfUVFkxhHhsNwVY+EBAz0QBBUGIJmHX7AO0tJ+pK+F0wwiUoTED7PHuCRgx7T ra+0dye+XLPOtXUKQeuiRPSx4ExdBh/ZZ3sL6H0panRCdavUggdA7lLzFyZvFyqmunyW Y3Ja7JiZZgxIF9JG+R9uICmpGXQZJ5OvRyX+eazWuVA7r53NHapBotp6zw4/19mWMYdb wCKbSzs1bxlER40/tyGtqoPJyeFHfh5k4iw9mb7y6S93QgXXYMddmeP/cH8rC+lfl6A/ ktCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si3742135pgf.374.2018.11.08.06.54.52; Thu, 08 Nov 2018 06:55:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbeKIAaI (ORCPT + 99 others); Thu, 8 Nov 2018 19:30:08 -0500 Received: from mail.bootlin.com ([62.4.15.54]:41968 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbeKIAaI (ORCPT ); Thu, 8 Nov 2018 19:30:08 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id E55D720970; Thu, 8 Nov 2018 15:54:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-30-49.w90-88.abo.wanadoo.fr [90.88.15.49]) by mail.bootlin.com (Postfix) with ESMTPSA id A0E6720510; Thu, 8 Nov 2018 15:54:14 +0100 (CET) Date: Thu, 8 Nov 2018 15:54:14 +0100 From: Boris Brezillon To: Cc: , , , , , , , Subject: Re: [PATCH 3/7] mtd: spi-nor: add restriction for nmaps in smpt parser Message-ID: <20181108155414.48b64084@bbrezillon> In-Reply-To: <4de81d92-ca8e-34f1-55b2-ef1b6b9dcec7@microchip.com> References: <20181108110653.21063-1-tudor.ambarus@microchip.com> <20181108110653.21063-4-tudor.ambarus@microchip.com> <20181108135447.36a0314c@bbrezillon> <86d16e39-15df-c12c-7bf3-25996db0c3a9@microchip.com> <20181108151509.364e3a85@bbrezillon> <4de81d92-ca8e-34f1-55b2-ef1b6b9dcec7@microchip.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 8 Nov 2018 14:48:11 +0000 wrote: > >>>> + > >>> > >>> Maybe I missed something but it sounds like this change is just > >>> optimizing the SPMT parsing a bit, and to be honest, I'm not sure this > >>> is really needed. Most of the time, smpt_len will be rather small, so > >>> trying to bail out earlier is not bringing much perf improvements. > >> > >> It's rather a smtp validity check. I want to return an error if there are not > >> enough detection commands to identify the map id. > > > > You would have failed the same way without this validity check after a > > maximum of smpt_len iterations, right? > > > > Right. The correct fix would be to count nmaps in a loop, then do these checks, > and if all ok, search for the map_id in another loop :). Or just error out when !ncmds && nmaps > 1. If you insist on keeping the ncmds && nmaps >= (1 << (ncmds + 1)) check, that's fine, but it's not replacing the consistency check I was doing ;-).