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 AADC831F9AC; Sun, 7 Jun 2026 10:40:51 +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=1780828853; cv=none; b=Eo78fGWeSfV6CYV6SdR/mYLVVcAibGdl8Qg83XrS9VJN6kam+Vvyqc4XDxLYTsjg+wWAmZXFNOHMe83qrz/Gda3t3LwmhIRbG+So1kOH5IrPIDYNq88tOa40SZfN3+8og9Ei1uM5Mm8szJZ5lye68x0wEjVu1dMGhp/W2NARVak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828853; c=relaxed/simple; bh=caEQiqMQ9TzF5VLIGO1Vxa+BbUjBEaUzvHdbGfaPgDw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u55QsjZHo++kQnP/VmzP5jEhaw7AxChd5nYv64zeTfo/3e1aIZwyoQmJdqWokqw8NyL7rLJ854folc8feehuX4TXhjGtROIiY9dUWpbFe1TMqbcgZFXSFLlYh+NQWvpyBtNZBe7EjnbocaPWP/qnChNCozO+ibtILK14xhIeDoo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VGao/6Ob; 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="VGao/6Ob" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BF971F00893; Sun, 7 Jun 2026 10:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828851; bh=CIAGThb6xSd3DLdksFxMtitGpoe0RMJfUGx7m9dMtkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VGao/6Ob+CUcsFxGefWxx31dPeWZxEZDq6QSvw7w9ILnJb+kQcnZoAZdlByMbdjFQ ayhpD92Dfmt22WN0WF8qDzNXwyE/azJO8VgCjKXjekOdD9VInxjoklOPG4rf8uGjLg 63MgiAx8wzNPXKfLomIStQ4qtJ3VcEvMVsGlqCM8= 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.12 164/307] iio: dac: max5821: fix return value check in powerdown sync Date: Sun, 7 Jun 2026 11:59:21 +0200 Message-ID: <20260607095733.745828139@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@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.12-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 @@ -91,6 +91,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; @@ -104,7 +105,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,