From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.10 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796298693; b=UIpI0aii2CF0Lo1Eq9mGlgl4FbwrHbngmc5KdgFAb0hWVccE+R7MlLbqvee0AydzhZ2I ujaXcsIpbb8wLXyvtGTtnOHozmD9/o/VQqyONTndDsW+mhWlZLq/IdZZgtF+IQb3UC3y6 3/i58LFufPyeUfjV7CGF24qzzSKbv4/xC8+o/ChtqlSSFvtK7P32+kPWpXD+xCz7g8zFt 5jpEiIT2gXnrRuZIo6JviNCR5Nic5Sw0GkTkjsCyFx2ToDyxFsw0TtYbnDPw8PbGRp6gB hShVkyc/W4GPZNIJdiR+NNj77OcQ1y+A+9o802dcyrYr8/csWQJR2H+vgpb5HB/TaJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796298693; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=zfrO8y13cyswqjTu5j/l2etYiEybHUVXjTTEx3qCZaw=; b=n15j7crDqAmFvclKd2gJllff8agNOyHKE1DP945+HaOVLB1BmBTENiN9zHJyO8HxxxGq 79GqfM6kJRPN1rRH7x4Ai1VWXYo5JRYtEPe7S/9PYKDdb25AAhNw7WlioFdHzWC7XBLrq XcyDKO6jleoCZ5iRhugL/TbdUF4eOEiBUA0UDDOJVb2FLWagscZw1PnKm9KHWqflcNXIR i2ckSQd4yQP7BCCpHZziFBeo1nDbVi9cbFqX5lo2TxNTNGis/khmBGH1oLFJj1SclF6XZ NM3VZc0ZZAArr7kzamUazMJLYz0hkjQKE9QmLfSmqtEdl268b+1lac3tK/YaiFUTN9w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QoWFTeEG; arc=none smtp.remote-ip=198.175.65.10 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3490606A322; Thu, 3 Dec 2026 11:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3490606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QoWFTeEG DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796298694; x=1827834694; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=zfrO8y13cyswqjTu5j/l2etYiEybHUVXjTTEx3qCZaw=; b=QoWFTeEGKFkZyA56NafWgbqRnBVnF41jdeHkpZ35f2uOZfV9Stp1lgRb w/lumygBsLstPMGLRBkIDTWmAoNY94qKV1/ql3b/W+Fk1D6JQ3sOyy/fU NihnnEveZXdQ1bOmC/FVaYmQBueXQBg9nzTWl7J4CXjiUC+iEx/Hbe0o+ KNy+q8HrK3j9BviAgpZaYW1vSMqYxY1x8eBkAC2Zh3fMH5uqr6tLHom7U I4j+2MQ5mjr1v26wfk1IG/L/Ce78BUZCLJSqVMWM5TwVVOxvDr/3RjE4o 4b+2TTC3kNUuNW0eo2aJq5IGWFkaOGeS+p4samq9td5RK49eR+L9djAeR Q==; X-CSE-ConnectionGUID: s9UBfRw2SMyPh7QyOiemmA== X-CSE-MsgGUID: 8zESsV2CT+WBEWVvFdHdfg== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5192487" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5192487" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 03:51:33 -0800 X-CSE-ConnectionGUID: L5BkAP69QvGWA8KgCa0VcQ== X-CSE-MsgGUID: QL2EJ2kuQR2+syis+4FXLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="13719632" Received: from inaky-mobl1.amr.corp.intel.com (HELO localhost) ([10.245.244.115]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 03:51:30 -0800 Date: Thu, 3 Dec 2026 13:51:27 +0200 From: Andy Shevchenko To: Lee Jones Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Nuno =?iso-8859-1?Q?S=E1?= , David Lechner , Jonathan Cameron , linux-iio@vger.kernel.org, Mathieu Othacehe Subject: Re: [PATCH v3 3/3] iio: proximity: isl29501: Fix division by zero and overflow in isl29501_set_freq() Message-ID: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Wed, Dec 02, 2026 at 08:21:12PM +0000, Lee Jones wrote: > isl29501_set_freq() computes freq = val * 1000000 + val2 % 1000000 in a > signed 32-bit int and passes it directly to do_div() without checking > for zero or negative inputs. Writing 0 to the sampling_frequency > attribute triggers a division by zero in the kernel, while valid > frequencies above 2147 Hz up to the sensor's 2222 Hz limit overflow > signed int. > > Validate val and val2 up front so that the requested frequency lies > within (0, 2222] Hz with val2 in [0, MICROHZ_PER_HZ), compute freq as > an unsigned int using MICROHZ_PER_HZ, and return -ERANGE otherwise. Reviewed-by: Andy Shevchenko ... > +++ b/drivers/iio/proximity/isl29501.c > #include > #include > #include > +#include Yes, the headers are mess in the driver, but please make them as #include #include #include #include #include #include #include #include #include #include (this will be a minimal intrusion with a small step towards an improvement). -- With Best Regards, Andy Shevchenko