From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4899F1FE47B; Sun, 7 Jun 2026 10:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828408; cv=none; b=rOV6M4V3LYrFKQSk5xVPZ2oC/eRxbqKXwMrv6JAfnxXCOVgOLWCP2hN1SI87hbo9r8k/X+BbwOX7j7ASsWnyz7fs5Do5imgrwkaLlqfWaEi+jH3mq07GzpvEhW9LjJe/inZFXtISde74iVo5a5riS34fU4CNVDhw6cg2FpGVD08= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828408; c=relaxed/simple; bh=omf4+G8klq6fCSMncJfkgw9vxlzvAVyMyIuNNDDq6/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MkErzHeAWfcruzGyM2/S6detoeROBRzsx3Q6VGtbiltzmMJa4fO0g8pRGH1RnU7M1Awslch8Qs0tfpTjD9nM91UZCPkzzoWf/xb0cRUwwlz2iu6kNaMAbYCksW3egA83Xs6WrkATElplH5Qz8EqcA62plalBNqVBIQcR9VHoOHg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eRJ/gDRi; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eRJ/gDRi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 590841F00893; Sun, 7 Jun 2026 10:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828407; bh=naekHRJOnBQetlT2bzwVcdtTbFrKrJ3GZw2xZhSQqBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eRJ/gDRiU++y+yAEkRuRXx012vb9FmL9iwnbUwOxyDK6LHobGiOhz89ad5uu++3er D4GxyliMBFZktaPrZf7SGX8X4X+BPOGWToOYYZ91fTUFLFp2fSAqzxnFf8laAqsVMa U7rVpEg4gotANpRDnoWTkakwaWAFcxh8y+lqj6uY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andy Shevchenko , Rodrigo Alencar , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 7.0 179/332] iio: dac: ad5686: fix input raw value check Date: Sun, 7 Jun 2026 11:59:08 +0200 Message-ID: <20260607095734.636911154@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095728.031258202@linuxfoundation.org> References: <20260607095728.031258202@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rodrigo Alencar commit d01220ee5e43c65a206df827b39bf5cf5f7b9dce upstream. Fix range check for input raw value, which is off by one, i.e., for a 10-bit DAC the max valid value is 1023, but 1 << 10 equals 1024, which passes the previous check, allowing an out-of-range write. The issue exists since the ad5686 driver was first introduced. Fixes: c2f37c8dcadc ("iio: dac: New driver for AD5686R, AD5685R, AD5684R Digital to analog converters") Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/dac/ad5686.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -154,7 +154,7 @@ static int ad5686_write_raw(struct iio_d switch (mask) { case IIO_CHAN_INFO_RAW: - if (val > (1 << chan->scan_type.realbits) || val < 0) + if (val >= (1 << chan->scan_type.realbits) || val < 0) return -EINVAL; mutex_lock(&st->lock);