On Thu, Sep 11, 2025 at 11:45:38PM +0200, Thorsten Blum wrote: > Replace kzalloc() followed by copy_from_user() with memdup_user() to > improve and simplify __hypfs_sprp_ioctl(). > > Return early if an error occurs instead of trying to allocate memory for > 'diag304' when memory allocation for 'data' already failed. > > No functional changes intended. > > Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx> > --- > arch/s390/hypfs/hypfs_sprp.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/arch/s390/hypfs/hypfs_sprp.c b/arch/s390/hypfs/hypfs_sprp.c > index 9fc3f0dae8f0..be11634bc7db 100644 > --- a/arch/s390/hypfs/hypfs_sprp.c > +++ b/arch/s390/hypfs/hypfs_sprp.c > @@ -73,15 +73,16 @@ static int __hypfs_sprp_ioctl(void __user *user_area) > void *data; > int rc; > > - rc = -ENOMEM; > data = (void *)get_zeroed_page(GFP_KERNEL); > - diag304 = kzalloc(sizeof(*diag304), GFP_KERNEL); > - if (!data || !diag304) > - goto out; > + if (!data) > + return -ENOMEM; > > - rc = -EFAULT; > - if (copy_from_user(diag304, user_area, sizeof(*diag304))) > + diag304 = memdup_user(user_area, sizeof(*diag304)); > + if (IS_ERR(diag304)) { > + rc = PTR_ERR(diag304); > goto out; > + } This is not an improvement and also incorrect, since kfree() may now be called with an error pointer. Please don't send patches like this which aren't a real improvement. This is just pointless code churn, and a waste of time.