[PATCH v4 57/59] alpha: switch osf_mount() to strndup_user()

Al Viro
2026-01-08T07:37:00Z

... same as native mount(2) is doing for devname argument. While we
are at it, fix misspelling ufs_args as cdfs_args in osf_ufs_mount() -
layouts are identical, so it doesn't change anything, but the current
variant is confusing for no reason.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
arch/alpha/kernel/osf_sys.c | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)

diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index a08e8edef1a4..7b6543d2cca3 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -454,42 +454,30 @@ static int
osf_ufs_mount(const char __user *dirname,
struct ufs_args __user *args, int flags)
{
- int retval;
- struct cdfs_args tmp;
- struct filename *devname;
+ struct ufs_args tmp;
+ char *devname __free(kfree) = NULL;

- retval = -EFAULT;
if (copy_from_user(&tmp, args, sizeof(tmp)))
- goto out;
- devname = getname(tmp.devname);
- retval = PTR_ERR(devname);
+ return -EFAULT;
+ devname = strndup_user(tmp.devname, PATH_MAX);
if (IS_ERR(devname))
- goto out;
- retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
- putname(devname);
- out:
- return retval;
+ return PTR_ERR(devname);
+ return do_mount(devname, dirname, "ext2", flags, NULL);
}

static int
osf_cdfs_mount(const char __user *dirname,
struct cdfs_args __user *args, int flags)
{
- int retval;
struct cdfs_args tmp;
- struct filename *devname;
+ char *devname __free(kfree) = NULL;

- retval = -EFAULT;
if (copy_from_user(&tmp, args, sizeof(tmp)))
- goto out;
- devname = getname(tmp.devname);
- retval = PTR_ERR(devname);
+ return -EFAULT;
+ devname = strndup_user(tmp.devname, PATH_MAX);
if (IS_ERR(devname))
- goto out;
- retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
- putname(devname);
- out:
- return retval;
+ return PTR_ERR(devname);
+ return do_mount(devname, dirname, "iso9660", flags, NULL);
}

static int
--
2.47.3