From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3455F2882BE for ; Thu, 20 Nov 2025 09:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763631469; cv=none; b=VjsbNStPZ8z3MMLviw5/30Oc/JIL0y/7W7R2ZueT2dC1CKTtoZ56uXUa3htbrX8ubd4+iAVeNzJnU42lqSCJxAMxhG6BiI02k5GszHDkax46TLg+IaiPACQGHAqGu4sBeAd+NE8E/FRD6SlvzoD74gqy6oQB1/x9RReARKVA6bo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763631469; c=relaxed/simple; bh=Jcjx9RlDQKspYeBRDfwatIA6Vj4r7d3hhFRseQLLq/Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y/C0qruo8DcUx0dVioluAjnT9RLVPWDPEW7jHUSvRYfl5C++IadD0aOqW3h3K4gYBWoghAKKLOcYsV0Gjba7EEYgG3eJln0RFkQ/MPscyY3s0EAJVB1k8K9awlR7r6bcuJNI8KnPkpQfj53lISv2bXZwTE3hEJM2gYh35E5LztY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V4a2Uiq2; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V4a2Uiq2" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-42bb288c1bfso398759f8f.2 for ; Thu, 20 Nov 2025 01:37:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763631465; x=1764236265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=pkWBxqMkAg+TZHlltBLGu08USzc1N005PN9aW6U8iIQ=; b=V4a2Uiq2rWR2tGma1udaOJyLfT1WOCmc5nlA8CpTygmFwS22AnGvEPAPu8UzU5mk/3 OPhp0a8CTdG21QnYSTQkJDCVwKe0T8+VsF86/z7fZxgx3+VuwUC1g4YqP020OJAkYnbC Uiq95WfBeF80mzUDUbwEs6Jwhc4mGFs0d+213XYizkA6pfawqbSuIydd0KtxfVSWtpdW AxQIrZX7hDUmU45XQmEqGybAp2sJnyoVBY8AxTe/wVYK3UYyydKqGDYjvp/xHaiyszL5 5Zf4X9nfRvxSMDDsVbyLvxHLGrnw5RUuNT8Z7zRc2y5XKcGGLcDf/LdW2YvdehIUs9s0 y7DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763631465; x=1764236265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pkWBxqMkAg+TZHlltBLGu08USzc1N005PN9aW6U8iIQ=; b=sRVKwA0jEAu8VlXLm+E4Tt3l7iL+xAUvBWz8He5ydtsjFqxIlcblaXLWaw+CpdO18w ZiAf75M7w3Ago1xEFro8MxH3aJ7370g2MBDADNGGK5ClyTIootBZHxXZeFp5GQdbqiTg LnHe83qQ9N+wnOvTlXAxrPecF+EWYSLZH4LWTlpJIEUHY5FH7YCDfYQN4xdCZpceyLze u1XuSPvmmQiZgSrxIApLHUErc+CFgEvdh7otfGEG8yWjlOk0+pWVL+Ye66+KJOWqk4GC 6j89hyIw1SMwinea4Bc1rpMLtJk1pKIMJ5I/5fquVKXKyomWlglAH1DKmv5H8N98r06w NiGg== X-Gm-Message-State: AOJu0YyVkFF4bxWGwc1kX6D25hNXHkAEz3INHtqqeOa4D3fdxfXZKLOD fsCDb+M2K3GN7ofhPRdexiyzf7KcFS6qJsC9vRztWPitX6YpP5DSAIH9pJpPGg== X-Gm-Gg: ASbGncs1mQiHmsrwIOlpXzswbMyTBgY01EMOwHtU8TTS7uVOfabdMH/WNfw69Ch/neo f0XqPL+UR6D8RX6UzCu1o93s7W2tKNqDnabCWBb5QhX8q8woRcC/k7O9E98Xp2aPUYJ8ZWzhOv9 ehXV0FsX35XKikmnSL0y1aQTPaZNodJBtg4STHGUWQuv/AU0rmSvR0duh45eSzeipDlDqBASLbE e5V3bl9W77vKq+taLki9NKIbpyciMHCfOP963wcRRh1jTo5GRxdmQIbtpte1e7HQQr7s3LTNczp RbBM2Xas2/E7wU+NfIJiokQEex34rVXhTlf3euLo9qheYw2W0aKHGkCyDYCcu952oP7EdQ/9Vj+ COH5OPif5U35/FP+pMryZjR9T6YR+8foDKdfCEjBuXSuTgYF5TzG9hXCtGqYP845L+zjB1zAbS1 OLeZ+1cbG1gfFCS1hrmUAh/dhqLKt/VRVynqofPCwRPL2YGWizVZa+ X-Google-Smtp-Source: AGHT+IEBbsWHpnh9JsKgNdQcSKiP2aNRlDfbsa63SARDaFG0te32/bw2tIoEKmReQNGzJ55jft0ejA== X-Received: by 2002:a05:6000:1841:b0:429:b9bc:e826 with SMTP id ffacd0b85a97d-42cb9a70d18mr2246350f8f.53.1763631465014; Thu, 20 Nov 2025 01:37:45 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7fa35b7sm4335916f8f.20.2025.11.20.01.37.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 01:37:44 -0800 (PST) Date: Thu, 20 Nov 2025 09:37:43 +0000 From: David Laight To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , Mika Westerberg Subject: Re: [PATCH 18/44] drivers/gpio: use min() instead of min_t() Message-ID: <20251120093743.1cf9bb8f@pumpkin> In-Reply-To: References: <20251119224140.8616-1-david.laight.linux@gmail.com> <20251119224140.8616-19-david.laight.linux@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit On Thu, 20 Nov 2025 10:01:29 +0200 Andy Shevchenko wrote: > On Wed, Nov 19, 2025 at 10:41:14PM +0000, david.laight.linux@gmail.com wrote: > > > > min_t(u16, a, b) casts an 'unsigned long' to 'u16'. > > Use min(a, b) instead as it promotes the both values to int > > and so cannot discard significant bits. > > > > In this case the values should be ok. > > > > Detected by an extra check added to min_t(). > > In most of the patches you need to follow the commonly used Subject prefix. > This can be done by doing I did look up quite a few files to see what had been used previously. But it is a bit tedious with 44 patches. > git log --oneline --no-merges -- $FILE(S)_OF_INTEREST I wasn't aware of that spell :-) ... > > > acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, > > > - length = min_t(u16, agpio->pin_table_length, pin_index + bits); > > + length = min(agpio->pin_table_length, pin_index + bits); > > Now, if you look closer at the code, the pin_index alone has the problem you > are targeting here. The compiler warning happens because 'pin_index + bits' is 'int' and the compiler doesn't know the value fits in 16 bits. It should fit, but only if the caller passes in valid data. > On top of that the iterator and 'length' are signed, while > the result of min_t(u16) is unsigned (however it has no difference in this case). Actually the result type of min_t(u16) is 'int' (:? promotes char/short to int). So the u16 cast does '(pin_index + bits) & 0xffff', everything is then promoted to 'int' for all the comparisons (etc). David > > ... > > TL;DR: I apply this patch with subject changed, but I think more work needs to > be done if you want to fix it fully. >