]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: cs35l56: Fix wrong error test on simple_write_to_buffer()
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 11 Jun 2026 15:12:34 +0000 (16:12 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 11 Jun 2026 19:39:06 +0000 (20:39 +0100)
In cs35l56_cal_data_debugfs_write() fix the if statement that checks for
error return to only check for negative values.

Reported by Sashiko:

  simple_write_to_buffer() returns the positive number of bytes copied
  on success. Since the condition returns immediately on any non-zero
  value, is it possible that the written calibration data is discarded
  and cs35l56_stash_calibration() is never called?

Fixes: f7097161e94c ("ASoC: cs35l56: Add common code for factory calibration")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260610093432.557375-1-rf%40opensource.cirrus.com
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260611151234.1111153-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs35l56-shared.c

index d9f237bf8168c9571c725fd3d0df68296c16e4fd..f14e2eaaa4ee4cfd14b6e634c2b292bd4002b24a 100644 (file)
@@ -1260,7 +1260,7 @@ ssize_t cs35l56_cal_data_debugfs_write(struct cs35l56_base *cs35l56_base,
                return -EMSGSIZE;
 
        ret = simple_write_to_buffer(&cal_data, sizeof(cal_data), ppos, from, count);
-       if (ret)
+       if (ret < 0)
                return ret;
 
        ret = cs35l56_stash_calibration(cs35l56_base, &cal_data);