From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 835C046520; Wed, 20 Dec 2023 15:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="394718101" X-IronPort-AV: E=Sophos;i="6.04,291,1695711600"; d="scan'208";a="394718101" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 07:54:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="867014290" X-IronPort-AV: E=Sophos;i="6.04,291,1695711600"; d="scan'208";a="867014290" Received: from smile.fi.intel.com ([10.237.72.54]) by FMSMGA003.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 07:54:11 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rFytb-00000007aqH-45CW; Wed, 20 Dec 2023 17:54:07 +0200 Date: Wed, 20 Dec 2023 17:54:07 +0200 From: Andy Shevchenko To: Hugo Villeneuve Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org, jringle@gridpoint.com, kubakici@wp.pl, phil@raspberrypi.org, bo.svangard@embeddedart.se, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Hugo Villeneuve Subject: Re: [PATCH 13/18] serial: sc16is7xx: use in_range() for DT properties bound checks Message-ID: References: <20231219171903.3530985-1-hugo@hugovil.com> <20231219171903.3530985-14-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231219171903.3530985-14-hugo@hugovil.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Tue, Dec 19, 2023 at 12:18:57PM -0500, Hugo Villeneuve wrote: > From: Hugo Villeneuve > > Improve code readability and efficiency by using in_range() when checking > device tree properties bound. ... > count = device_property_count_u32(dev, "irda-mode-ports"); > - if (count < 0 || count > SC16IS7XX_MAX_PORTS) > + if (!in_range(count, 0, SC16IS7XX_MAX_PORTS + 1)) > return; Okay, looking at this, it becomes uglier than initial code, means my suggestion was not good. Please, drop this patch. -- With Best Regards, Andy Shevchenko