ipc: preserve original file opening pattern
Hello Christian Brauner,
Commit ea2f85c54e81 ("ipc: preserve original file opening pattern") from Nov 26, 2025 (linux-next), leads to the following Smatch static checker warning:
ipc/mqueue.c:907 mqueue_file_open() warn: passing positive error code '1' to 'ERR_PTR'
ipc/mqueue.c
889 static struct file *mqueue_file_open(struct filename *name,
890 struct vfsmount *mnt, int oflag, bool ro,
891 umode_t mode, struct mq_attr *attr)
892 {
893 struct path path __free(path_put) = {};
894 struct dentry *dentry;
895 struct file *file;
896 int ret;
897
898 dentry = start_creating_noperm(mnt->mnt_root, &QSTR(name->name));
899 if (IS_ERR(dentry))
900 return ERR_CAST(dentry);
901
902 path.dentry = dentry;
903 path.mnt = mntget(mnt);
904
905 ret = prepare_open(path.dentry, oflag, ro, mode, name, attr);
906 if (ret)--> 907 return ERR_PTR(ret);
prepare_open() can return 1 if the ro (read only) variable is true and Smatch complains if we pass a positive to ERR_PTR().
908
909 file = dentry_open(&path, oflag, current_cred());
910 end_creating(dentry);
911 return file;
912 }regards,
dan carpenter