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 39D1B3D091A; Tue, 16 Jun 2026 18:09:47 +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=1781633388; cv=none; b=LKpiA6SPoqqKYH9bBJGYI0pqOHXI/GcG8XilxGbRWDFfJvGu8hHzoLTgvSJS2sRnTAGbk6aEkgQvLUWfnDNUzM3O1z6GuvBT8N0INE+GLIYFXBeuo9vshI5MadaTmIlrJCTn7wzxatfvFrkKwvJQhU7H+f/SxEFJUznMdUWioWI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781633388; c=relaxed/simple; bh=nCUmfZWyBM8ntZgoG/95lQ5QCTNHifVPm+W1uLHp26E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XOo1YiEd8mg9XCTYzTKu18Bfrlr9gg8QbaqGEXAdVHRyV0ba6TPHvtccEhUiiqBGinZMjP5J/M9u5B33ADLB3X7kws+4XxGUpO0ljFISeo31A4WkvGTIiezqx5OFCosU194vEFUdssOZE6/EwGzlaWTMnqqI0qFXJQU1x3WmTVE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CoQH35LG; 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="CoQH35LG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 263E01F000E9; Tue, 16 Jun 2026 18:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781633387; bh=henLNC7xkL9XQyMLLrXpQe/XEEAwOw2QLqAw8gFM23w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CoQH35LGIBCQqBKZ40g6FTVNj8BQtSjVkjNREqhstr+Q139TIe7OyfIsQqnP2j69+ Xf9J6fbrueeswpVhGd9O23cAag6DFw9+srKfO9a8evhiAlyTS6njOHGlyLprd2LnAN MbfVtlHRD+SUbgVSo11NIaoF6xCyKF+44tkhrnaY= 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 5.15 069/411] iio: dac: max5821: fix return value check in powerdown sync Date: Tue, 16 Jun 2026 20:25:07 +0530 Message-ID: <20260616145103.950605511@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145100.376842714@linuxfoundation.org> References: <20260616145100.376842714@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 5.15-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,