All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Wesley Sheng <wesley.sheng@microchip.com>
Cc: kurt.schwemmer@microsemi.com, logang@deltatee.com,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	wesleyshenggit@sina.com
Subject: Re: [PATCH 3/5] switchtec: A temporary variable should be used for the flags of switchtec_ioctl_event_ctl
Date: Wed, 12 Dec 2018 16:43:15 -0600	[thread overview]
Message-ID: <20181212224315.GK99796@google.com> (raw)
In-Reply-To: <1544433144-7563-4-git-send-email-wesley.sheng@microchip.com>

On Mon, Dec 10, 2018 at 05:12:22PM +0800, Wesley Sheng wrote:
> From: Joey Zhang <joey.zhang@microchip.com>
> 
> For nr_idxs is larger than 1 switchtec_ioctl_event_ctl event flags will be
> used by each event indexes. In current implementation the event flags are
> overwritten by first call of the function event_ctl().
> 
> Preserve the event flag value with a temporary variable.
> 
> Fixes: 52eabba5bcdb ("switchtec: Add IOCTLs to the Switchtec driver")
> Signed-off-by: Joey Zhang <joey.zhang@microchip.com>
> Signed-off-by: Wesley Sheng <wesley.sheng@microchip.com>
> Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> ---
>  drivers/pci/switch/switchtec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index 480107e..a908670 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -796,6 +796,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
>  {
>  	int ret;
>  	int nr_idxs;
> +	unsigned int event_flags;
>  	struct switchtec_ioctl_event_ctl ctl;
>  
>  	if (copy_from_user(&ctl, uctl, sizeof(ctl)))
> @@ -817,7 +818,9 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
>  		else
>  			return -EINVAL;
>  
> +		event_flags = ctl.flags;
>  		for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) {
> +			ctl.flags = event_flags;
>  			ret = event_ctl(stdev, &ctl);

event_ctl() overwrites several other things, in addition to ctl.flags:

  ctl.data[]
  ctl.occurred
  ctl.count

Is that what you intend?  It looks like only the values from the *last*
call of event_ctl() will be copied back to the user buffer.

>  			if (ret < 0)
>  				return ret;
> -- 
> 2.7.4
> 

  reply	other threads:[~2018-12-12 22:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10  9:12 [PATCH 0/5] Switchtec MRPC DMA mode support Wesley Sheng
2018-12-10  9:12 ` [PATCH 1/5] switchtec: Remove immediate status check after submit a MRPC command Wesley Sheng
2018-12-10  9:12 ` [PATCH 2/5] switchtec: Set DMA coherent mask in Switchtec driver Wesley Sheng
2018-12-10  9:12 ` [PATCH 3/5] switchtec: A temporary variable should be used for the flags of switchtec_ioctl_event_ctl Wesley Sheng
2018-12-12 22:43   ` Bjorn Helgaas [this message]
2018-12-12 22:52     ` Logan Gunthorpe
2018-12-10  9:12 ` [PATCH 4/5] switchtec: Improve MRPC efficiency by leveraging write combining Wesley Sheng
2018-12-10  9:12 ` [PATCH 5/5] switchtec: MRPC DMA mode implementation Wesley Sheng
2018-12-12 22:52   ` Bjorn Helgaas
2018-12-12 22:58     ` Logan Gunthorpe
2018-12-13 15:16       ` Bjorn Helgaas
2018-12-13 15:17   ` Bjorn Helgaas
2018-12-13 16:46     ` Logan Gunthorpe
2018-12-13 15:20 ` [PATCH 0/5] Switchtec MRPC DMA mode support Bjorn Helgaas
  -- strict thread matches above, loose matches on Subject: below --
2018-11-15  9:43 Wesley Sheng
2018-11-15  9:44 ` [PATCH 3/5] switchtec: A temporary variable should be used for the flags of switchtec_ioctl_event_ctl Wesley Sheng

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=20181212224315.GK99796@google.com \
    --to=helgaas@kernel.org \
    --cc=kurt.schwemmer@microsemi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=wesley.sheng@microchip.com \
    --cc=wesleyshenggit@sina.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.