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 891731FE47B; Sun, 7 Jun 2026 10:33:23 +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=1780828404; cv=none; b=ZdvISoK0hiEYbwtO3wzvEnk7ZOvXW13TMm3YsxfhDO+1Ob+zDqfIvp9SyZpU4Y4YuqSgqz7zaEnqGT/1J/VDomzyMSCxThCrQIeACW6dVZS4ZrXfw+ij6py7SjBcCYT2BS2hJCaWPpHH/AXEgZrfg1bGxySP6iECGBkwspoJ8cY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828404; c=relaxed/simple; bh=yG6XSsN3vvaCIId1Pvd6Z8aj26+t91x8LUiPHKZudvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hJjaNnhDbW5pNkfm7a7nyKvaKx0JMWnsJmNI9mThLBlQnkb257r0/AZH0bGNgQ2zb0rno19Q9CJgh1f1A5B95eWR9CVJDb9FfRPBx7zEJSeFRkMUo6EJjsDO91nSX1xyfX3Uv9XafcdRGyAOog9moPRUctUogW5DDwYnM2ba8MU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Msq2oRQa; 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="Msq2oRQa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1A951F00893; Sun, 7 Jun 2026 10:33:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828403; bh=nrsMtx5XfrtDwdRLEWAbR0T29FcE8V8BykrCU82j450=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Msq2oRQaIeyKD4WWMeM0Hkc3PdCoXJ4zX6V1S36cnr1Y9y/KdzSC3jyruZJ5lY01z pt4uj6ZKfSOWod7aGPkgxnWcNgtlNApJ2m0/SfETdTq6VeAdcRKkNcPH7YwCB9riyO ItK9EvsUcuir9SVjkvpDLlED4MW8xcj5TMJ0M4WA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Salah Triki , Andy Shevchenko , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.18 156/315] iio: dac: max5821: fix return value check in powerdown sync Date: Sun, 7 Jun 2026 11:59:03 +0200 Message-ID: <20260607095733.328970061@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Salah Triki commit d0a228d903425e653f18a4341e60c0538afb6d41 upstream. The function max5821_sync_powerdown_mode() returned the result of i2c_master_send() directly. If a partial transfer occurred, it would be incorrectly treated as a success by the caller. While the caller currently handles the positive return value of 2 as success, this patch refactors the function to return 0 on full success and -EIO on short writes. This ensures robust error handling for incomplete transfers and improves code maintainability by using sizeof(outbuf). Fixes: 472988972737 ("iio: add support of the max5821") Signed-off-by: Salah Triki Reviewed-by: Andy Shevchenko Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/dac/max5821.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/iio/dac/max5821.c +++ b/drivers/iio/dac/max5821.c @@ -90,6 +90,7 @@ static int max5821_sync_powerdown_mode(s const struct iio_chan_spec *chan) { u8 outbuf[2]; + int ret; outbuf[0] = MAX5821_EXTENDED_COMMAND_MODE; @@ -103,7 +104,13 @@ static int max5821_sync_powerdown_mode(s else outbuf[1] |= MAX5821_EXTENDED_POWER_UP; - return i2c_master_send(data->client, outbuf, 2); + ret = i2c_master_send(data->client, outbuf, sizeof(outbuf)); + if (ret < 0) + return ret; + if (ret != sizeof(outbuf)) + return -EIO; + + return 0; } static ssize_t max5821_write_dac_powerdown(struct iio_dev *indio_dev,