提交 4afd2b41 编写于 作者: J Joey Zhang 提交者: Xie XiuQi

switchtec: Fix SWITCHTEC_IOCTL_EVENT_IDX_ALL flags overwrite

[ Upstream commit e4a7dca5de625018b29417ecc39dc5037d9a5a36 ]

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: 52eabba5 ("switchtec: Add IOCTLs to the Switchtec driver")
Signed-off-by: NJoey Zhang <joey.zhang@microchip.com>
Signed-off-by: NWesley Sheng <wesley.sheng@microchip.com>
[bhelgaas: changelog]
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: NLogan Gunthorpe <logang@deltatee.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ba1c5863
...@@ -800,6 +800,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev, ...@@ -800,6 +800,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)))
...@@ -821,7 +822,9 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev, ...@@ -821,7 +822,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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册