ANDROID: Incremental fs: Use ERR_CAST in handle_mapped_file()
When building android-mainline with a version of clang that supports
CONFIG_RANDSTRUCT, there are errors about casts from randomized
structures to non-randomized structures:
fs/incfs/data_mgmt.c:240:10: error: casting from randomized structure pointer type 'struct dentry *' to 'struct data_file *'
return (struct data_file *)index_file_dentry;
^
fs/incfs/data_mgmt.c:257:12: error: casting from randomized structure pointer type 'struct file *' to 'struct data_file *'
result = (struct data_file *)bf;
^
2 errors generated.
As suggested by Kees on aosp/1995750, these casts should actually be
using the ERR_CAST macro, which is a more proper way to pass error
pointers around.
Change-Id: Iab73ac7503235f1147154a01a22ab8608e3daf8b
Fixes: 3f4938108a ("ANDROID: Incremental fs: Create mapped file")
Link: https://github.com/ClangBuiltLinux/linux/issues/1652
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This commit is contained in:
parent
0f0ddc32df
commit
483887d651
1 changed files with 2 additions and 2 deletions
|
|
@ -237,7 +237,7 @@ static struct data_file *handle_mapped_file(struct mount_info *mi,
|
|||
if (!index_file_dentry)
|
||||
return ERR_PTR(-ENOENT);
|
||||
if (IS_ERR(index_file_dentry))
|
||||
return (struct data_file *)index_file_dentry;
|
||||
return ERR_CAST(index_file_dentry);
|
||||
if (!d_really_is_positive(index_file_dentry)) {
|
||||
result = ERR_PTR(-ENOENT);
|
||||
goto out;
|
||||
|
|
@ -254,7 +254,7 @@ static struct data_file *handle_mapped_file(struct mount_info *mi,
|
|||
revert_creds(old_cred);
|
||||
|
||||
if (IS_ERR(bf)) {
|
||||
result = (struct data_file *)bf;
|
||||
result = ERR_CAST(bf);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue