From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 9837328FFF6 for ; Tue, 23 Jun 2026 05:31:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782192716; cv=none; b=o4yJUkEqRIYOTdl7E6B3/rZUaAtsNJ1F7hWm8qsfD0JIM2rz4Gvw3WlVJ0ASharjGtNgm3EG9rAkkFor7gYpDRgJPqS5K56oQvkEUTSEJfg3z+nxnhHsIUzjw+n99kI10aG7kohd04QDfqzytSOkepBkO58cqyd8ADp1s9bjBao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782192716; c=relaxed/simple; bh=G7gSFJmNGNC/nlv8QHYHAAJ+I84JI0QUN9HfeUOXXmE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=b15lKD530Y48SzgzuUQ0wcHVd0upP6qVKLOiZhq12cp0/UGOT7JBt28wsoAHzSX5Aoswsg+etopFhT+C9ENlUoCyEl/CjCPeVj+AxVonCz2LAkaJdRdr3+/ipTS7uWRESKXunYlKotgmuPEqyZprpAHbaI9OIOrneOWExU4gIMo= 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=nKpVDrsr; arc=none smtp.client-ip=74.125.82.45 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="nKpVDrsr" Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-139986373b8so5596043c88.0 for ; Mon, 22 Jun 2026 22:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782192715; x=1782797515; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1hhjI0s8nXHkgGSUH3JS/n/cfolCeudCVnQ8IdgzgVU=; b=nKpVDrsrrs+jQh2iBI1E0ssAmTlWtOB+YyYYs780bdV3xqW2hZxOdtso6fZAG0vEIm GtoeOCDYLJ8VHwNoUY5NnYjunzwS8GyV8Pf9TD3geZMB1sMHU4d2AhDE9UwfgeHvZ/b0 am86rYA48oPfCR7nKJMCLVfEyKkj4j4JmWSr5ZrOeHn+dOYTqQ6FvLWfZVHbBB7WiITP sHKPGmqcQIqrf31E+0Q4o/B3BfOLeoUmVrudOYSUUjqBSiIpDvBv0mUC42tE6afQ8OBF SvYaeQtJLzLXiar58rEeuKqQgRFTf2rEwxKXU0KARDLpzUkwoR2Vz2wUcU5d/Flly7co 0AbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782192715; x=1782797515; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1hhjI0s8nXHkgGSUH3JS/n/cfolCeudCVnQ8IdgzgVU=; b=IrDL6bKuja59BcWpLdoY9HAAhwVg6PkIn4ZX2A9WFWsqIuJCZX2MffnbG4HSUWzvtD Kw7+MNM5sLsPCByy8AI3yqhES1AWdtke4UhWMjYdeui4cAhjOSa6CkKw5uzOluAzRUsb 8kEHBsvCFdRQAj787b2fywC1JKvYzvid9r0XfhZaeZZmIcFM9/jRiDSDk9tQab6I/qr3 hDUTcej3mN1SaByI2vfyg1JPgdJA3SqcQ1bzZZBWlr0WYWeaOMoIeYkLuc/Y3UtMymjI dRiDp15S2ta2VPmkPl9itUGRbtTxYXHX4fvO/ryQTXiRvGg5NR/lgDHjYIjfgG646b5H eWtQ== X-Forwarded-Encrypted: i=1; AFNElJ9C4invVbn60340K9Lp394jtaZs6Gn8c1qXUdwP9lp5DSeyEvUTqJzlDd0UWsnmy73EXzX0fI9r0P3VK80=@vger.kernel.org X-Gm-Message-State: AOJu0YygfQIcPxivN1k34nl9JoWxi2PQYzTkciOJTa+Cj3ElLnoq4af5 DZYno89YkrEh50MJCXTBF1xFd7wUSH6EzlpGd4Y6Wh+4eA95vzaaeEGD X-Gm-Gg: AfdE7cnXjPaD+GORD4Jb3C3r0xQlX5Rg7aRWpsTFFUkoFb9jMR5a5xzJU96018GC9V1 aDrlpmX2afarbhfsM5cw3qHvuqxxxPxAr5BfyUKNxeyg8a9JYQfUPlbv/z31ECHTEShjAXREhMs EiSu31fxT4zthJwhIDOF1dlnkdS31XS03bfyEQ599S8tAX3dVhQvYgzrvJc3NLYmalyMckzr44N sK/lmqrqf8ffh6fUnVSUETLWp/xxMrX1EwnKKO9b3Q/Jkd7xAj1r1uHgU/5gUcjVoIGw7jShjUH VTntIxtOVdqTOgRu0Ctv33C7Mq9oc4JhKY1KU3Rs1JEZbcJCZ2Lw0sztlebZKYBO3LMSlFS2QSb bpzPorIIp1FkR88giymbGKp8oA+Iu2cczTLcNSZfzF2qEVxXoGOjcbjKXTgfOkETZoSqSuo9+r0 Y8GRLFSoHxePgWF86Wpjo4AmfBSJHxLhGvN1cftqibAQ19NI3UZdq1cw== X-Received: by 2002:a05:7022:921:b0:132:f16:a574 with SMTP id a92af1059eb24-139c6ebfda0mr674667c88.7.1782192714580; Mon, 22 Jun 2026 22:31:54 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:7d8d:3bdf:d563:1911]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-139adcb7a94sm10869884c88.4.2026.06.22.22.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 22:31:53 -0700 (PDT) Date: Mon, 22 Jun 2026 22:31:51 -0700 From: Dmitry Torokhov To: Ranjan Kumar Cc: bleung@chromium.org, bentiss@kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] Input: elan_i2c - prevent division by zero and arithmetic underflow Message-ID: References: <20260612060339.3829666-1-kumarranja@chromium.org> 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: <20260612060339.3829666-1-kumarranja@chromium.org> On Fri, Jun 12, 2026 at 06:03:39AM +0000, Ranjan Kumar wrote: > The Elan I2C touchpad driver queries the device for its physical > dimensions and trace counts to calculate the device resolution and width. > However, if the device firmware or device tree provides invalid zero > values for x_traces or y_traces, it results in a fatal division-by-zero > exception leading to a kernel panic during device probe. > > Add checks to ensure these parameters are non-zero before performing > the division. If invalid trace values are detected, fall back to a safe > default of 1. > > Additionally, prevent an arithmetic underflow in the touch reporting > logic. Previously, if the calculated or fallback width was smaller than > ETP_FWIDTH_REDUCE (90), the subtraction would underflow, resulting in a > massive unsigned integer being reported to userspace. Clamp the adjusted > width to a minimum of 0 to safely handle small physical dimensions and > fallback scenarios. > > Completing the probe with safe fallback values ensures the sysfs nodes > are created, keeping the firmware update path intact so a recovery > firmware can be flashed to the device. > > Fixes: 6696777c6506 ("Input: add driver for Elan I2C/SMbus touchpad") > Fixes: e3a9a1290688 ("Input: elan_i2c - do not query the info if they are provided") > Signed-off-by: Ranjan Kumar Applied, thank you. -- Dmitry