Commit 21fed407 authored by Stephen Hemminger's avatar Stephen Hemminger

[BRIDGE]: Kill excessive stack usage in br_ioctl.

parent 419c3e2e
...@@ -84,17 +84,20 @@ static int br_ioctl_device(struct net_bridge *br, ...@@ -84,17 +84,20 @@ static int br_ioctl_device(struct net_bridge *br,
case BRCTL_GET_PORT_LIST: case BRCTL_GET_PORT_LIST:
{ {
int i; int *indices;
int indices[256]; int ret = 0;
for (i=0;i<256;i++) indices = kmalloc(256*sizeof(int), GFP_KERNEL);
indices[i] = 0; if (indices == NULL)
return -ENOMEM;
memset(indices, 0, 256*sizeof(int));
br_get_port_ifindices(br, indices); br_get_port_ifindices(br, indices);
if (copy_to_user((void *)arg0, indices, 256*sizeof(int))) if (copy_to_user((void *)arg0, indices, 256*sizeof(int)))
return -EFAULT; ret = -EFAULT;
kfree(indices);
return 0; return ret;
} }
case BRCTL_SET_BRIDGE_FORWARD_DELAY: case BRCTL_SET_BRIDGE_FORWARD_DELAY:
...@@ -212,19 +215,24 @@ static int br_ioctl_deviceless(unsigned int cmd, ...@@ -212,19 +215,24 @@ static int br_ioctl_deviceless(unsigned int cmd,
case BRCTL_GET_BRIDGES: case BRCTL_GET_BRIDGES:
{ {
int i; int *indices;
int indices[64]; int ret = 0;
for (i=0;i<64;i++)
indices[i] = 0;
if (arg1 > 64) if (arg1 > 64)
arg1 = 64; arg1 = 64;
indices = kmalloc(arg1*sizeof(int), GFP_KERNEL);
if (indices == NULL)
return -ENOMEM;
memset(indices, 0, arg1*sizeof(int));
arg1 = br_get_bridge_ifindices(indices, arg1); arg1 = br_get_bridge_ifindices(indices, arg1);
if (copy_to_user((void *)arg0, indices, arg1*sizeof(int)))
return -EFAULT;
return arg1; ret = copy_to_user((void *)arg0, indices, arg1*sizeof(int))
? -EFAULT : arg1;
kfree(indices);
return ret;
} }
case BRCTL_ADD_BRIDGE: case BRCTL_ADD_BRIDGE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment