public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Ruan Jinjie <ruanjinjie@huawei.com>
Cc: linux-s390@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>
Subject: Re: [PATCH -next] s390/hmcdrv: Switch to memdup_user_nul() helper
Date: Tue, 15 Aug 2023 14:13:41 +0200	[thread overview]
Message-ID: <20230815121341.18151-A-hca@linux.ibm.com> (raw)
In-Reply-To: <20230815115546.1604722-1-ruanjinjie@huawei.com>

On Tue, Aug 15, 2023 at 07:55:46PM +0800, Ruan Jinjie wrote:
> Use memdup_user_nul() helper instead of open-coding
> to simplify the code.
> 
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
> ---
>  drivers/s390/char/hmcdrv_dev.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/s390/char/hmcdrv_dev.c b/drivers/s390/char/hmcdrv_dev.c
> index 8d50c894711f..504cdbf9998d 100644
> --- a/drivers/s390/char/hmcdrv_dev.c
> +++ b/drivers/s390/char/hmcdrv_dev.c
> @@ -252,19 +252,12 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
>  		 fp, (long long) *pos, len);
>  
>  	if (!fp->private_data) { /* first expect a cmd write */
> -		fp->private_data = kmalloc(len + 1, GFP_KERNEL);
> -
> -		if (!fp->private_data)
> -			return -ENOMEM;
> -
> -		if (!copy_from_user(fp->private_data, ubuf, len)) {
> -			((char *)fp->private_data)[len] = '\0';
> -			return len;
> +		fp->private_data = memdup_user_nul(ubuf, len);
> +		if (IS_ERR(fp->private_data)) {
> +			fp->private_data = NULL;
> +			return PTR_ERR(fp->private_data);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is obviously broken. Sorry, but I'm not willing to review such
"trivial" cleanup patches for subtle bugs anymore - maybe you would
sooner or later succeed and I would apply such a broken patch.

Just don't send such patches; at least I won't take them.

      reply	other threads:[~2023-08-15 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 11:55 [PATCH -next] s390/hmcdrv: Switch to memdup_user_nul() helper Ruan Jinjie
2023-08-15 12:13 ` Heiko Carstens [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230815121341.18151-A-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=svens@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox