mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
switchtec: Fix SWITCHTEC_IOCTL_EVENT_IDX_ALL flags overwrite
In the ioctl_event_ctl() SWITCHTEC_IOCTL_EVENT_IDX_ALL case, we call
event_ctl() several times with the same "ctl" struct. Each call clobbers
ctl.flags, which leads to the problem that we may not actually enable or
disable all events as the user requested.
Preserve the event flag value with a temporary variable.
Fixes: 52eabba5bc
("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>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
This commit is contained in:
parent
aff614c633
commit
e4a7dca5de
@ -796,6 +796,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int nr_idxs;
|
int nr_idxs;
|
||||||
|
unsigned int event_flags;
|
||||||
struct switchtec_ioctl_event_ctl ctl;
|
struct switchtec_ioctl_event_ctl ctl;
|
||||||
|
|
||||||
if (copy_from_user(&ctl, uctl, sizeof(ctl)))
|
if (copy_from_user(&ctl, uctl, sizeof(ctl)))
|
||||||
@ -817,7 +818,9 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev,
|
|||||||
else
|
else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
event_flags = ctl.flags;
|
||||||
for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) {
|
for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) {
|
||||||
|
ctl.flags = event_flags;
|
||||||
ret = event_ctl(stdev, &ctl);
|
ret = event_ctl(stdev, &ctl);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user