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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD76C4332F for ; Wed, 16 Nov 2022 08:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231849AbiKPIRQ (ORCPT ); Wed, 16 Nov 2022 03:17:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238642AbiKPIRM (ORCPT ); Wed, 16 Nov 2022 03:17:12 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF036C2F; Wed, 16 Nov 2022 00:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668586631; x=1700122631; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=6E6aodHiBS2N1vbKhR1jmzSh1KadIn0j6YXcFDXzBFg=; b=jngspRpmgJAZTj8geVqLsb0hredJLDNFxiwIbZS/Vm0VYhDVtHkq0l7e R7SHsdiRzS+YUCqfUfjsPzuMArjIdgt3UWQK2B/YuVwmI+7iytaEbFapt sYG1qZ6HhWdjvnixxCBHy52uqDuheMiKSs4a25Fxay40QlqkmXB+pvJSQ Hcu28Sxxs06KRRKNKU4cHOkBgc/kcqICvaqAmk/b8qDeF6kJQw8y/Of1I oetbcKCre6EvpzT521mVV2LHSXH/sOtx0YTy7LwSpiofA3PxZ9NPeL8i1 l6shIS1f+wnyWwb2DkUR7SBazdULu2/sdfz7gmVHQu1clWzceTLos51kA g==; X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="300011533" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="300011533" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2022 00:17:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="590105251" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="590105251" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga003.jf.intel.com with ESMTP; 16 Nov 2022 00:17:09 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1ovDbY-00D2Qu-1C; Wed, 16 Nov 2022 10:17:08 +0200 Date: Wed, 16 Nov 2022 10:17:08 +0200 From: Andy Shevchenko To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Thierry Reding , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 3/4] pwm: Mark free pwm IDs as used in alloc_pwms() Message-ID: References: <20221115211515.3750209-1-u.kleine-koenig@pengutronix.de> <20221115211515.3750209-4-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221115211515.3750209-4-u.kleine-koenig@pengutronix.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-pwm@vger.kernel.org On Tue, Nov 15, 2022 at 10:15:14PM +0100, Uwe Kleine-König wrote: > alloc_pwms() only identified a free range of IDs and this range was marked > as used only later by pwmchip_add(). Instead let alloc_pwms() already do > the marking (which makes the function actually allocating the range and so > justifies the function name). This way access to the allocated_pwms > bitfield is limited to two functions only. This change is a bit fragile in a long term. Currently we know that we have no points of error after alloc_pwms() in ->probe(), but if somebody misses this in the future, we became to the case where bitmap might be exhausted (kinda resource leakage). -- With Best Regards, Andy Shevchenko