Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fsdax: dax_unshare_iter() should return a valid length

The copy_mc_to_kernel() will return 0 if it executed successfully. Then
the return value should be set to the length it copied.

[akpm@linux-foundation.org: don't mess up `ret', per Matthew]
Link: https://lkml.kernel.org/r/1675341227-14-1-git-send-email-ruansy.fnst@fujitsu.com
Fixes: d984648e428b ("fsdax,xfs: port unshare to fsdax")
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Shiyang Ruan and committed by
Andrew Morton
388bc034 aa1e6a93

+3 -2
+3 -2
fs/dax.c
··· 1271 1271 if (ret < 0) 1272 1272 goto out_unlock; 1273 1273 1274 - ret = copy_mc_to_kernel(daddr, saddr, length); 1275 - if (ret) 1274 + if (copy_mc_to_kernel(daddr, saddr, length) == 0) 1275 + ret = length; 1276 + else 1276 1277 ret = -EIO; 1277 1278 1278 1279 out_unlock: