All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yufen Yu <yuyufen@huawei.com>
Cc: axboe@kernel.dk, osandov@fb.com, linux-block@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] floppy: check_events callback should not return a negative number
Date: Mon, 28 Jan 2019 16:19:42 +0300	[thread overview]
Message-ID: <20190128131942.GH1795@kadam> (raw)
In-Reply-To: <20190128090646.44747-1-yuyufen@huawei.com>

On Mon, Jan 28, 2019 at 05:06:46PM +0800, Yufen Yu wrote:
> Since .check_events interface return an unsigned int value,
> floppy_check_events() should not return a negative error number.
> Otherwise, disk_check_events() may process wiht an unexpected path.
> 
> fixes: a0c80efe5956 ("floppy: fix lock_fdc() signal handling")
> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
> ---
>  drivers/block/floppy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 6f2856c6d0f2..55481b40df9a 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4075,7 +4075,7 @@ static unsigned int floppy_check_events(struct gendisk *disk,
>  
>  	if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
>  		if (lock_fdc(drive))
> -			return -EINTR;
> +			return 0;

The patch is correct, but I wish the commit message had said what the
run time impact of the patch is.  Or sometimes it's hard to say what the
run time impact is, but it could have at least said why returning zero
is correct.  Say something like:

  floppy_check_events() is supposed to return bit flags to say which
  events occured.  We should return zero to say that no event flags are
  set.  Only BIT(0) and BIT(1) are used in the caller.  This code
  returns -4u  here so both BIT(0) and BIT(1) are clear.  So this patch
  shouldn't affect runtime, but it obviously is still worth fixing.

regards,
dan carpenter

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yufen Yu <yuyufen@huawei.com>
Cc: axboe@kernel.dk, osandov@fb.com, linux-block@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] floppy: check_events callback should not return a negative number
Date: Mon, 28 Jan 2019 13:19:42 +0000	[thread overview]
Message-ID: <20190128131942.GH1795@kadam> (raw)
In-Reply-To: <20190128090646.44747-1-yuyufen@huawei.com>

On Mon, Jan 28, 2019 at 05:06:46PM +0800, Yufen Yu wrote:
> Since .check_events interface return an unsigned int value,
> floppy_check_events() should not return a negative error number.
> Otherwise, disk_check_events() may process wiht an unexpected path.
> 
> fixes: a0c80efe5956 ("floppy: fix lock_fdc() signal handling")
> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
> ---
>  drivers/block/floppy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 6f2856c6d0f2..55481b40df9a 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4075,7 +4075,7 @@ static unsigned int floppy_check_events(struct gendisk *disk,
>  
>  	if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
>  		if (lock_fdc(drive))
> -			return -EINTR;
> +			return 0;

The patch is correct, but I wish the commit message had said what the
run time impact of the patch is.  Or sometimes it's hard to say what the
run time impact is, but it could have at least said why returning zero
is correct.  Say something like:

  floppy_check_events() is supposed to return bit flags to say which
  events occured.  We should return zero to say that no event flags are
  set.  Only BIT(0) and BIT(1) are used in the caller.  This code
  returns -4u  here so both BIT(0) and BIT(1) are clear.  So this patch
  shouldn't affect runtime, but it obviously is still worth fixing.

regards,
dan carpenter

  parent reply	other threads:[~2019-01-28 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28  9:06 [PATCH] floppy: check_events callback should not return a negative number Yufen Yu
2019-01-28  9:06 ` Yufen Yu
2019-01-28  9:16 ` YueHaibing
2019-01-28  9:16   ` YueHaibing
2019-01-28 13:19 ` Dan Carpenter [this message]
2019-01-28 13:19   ` Dan Carpenter
2019-01-29  3:27   ` yuyufen
2019-01-29  3:27     ` yuyufen

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=20190128131942.GH1795@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=yuyufen@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.