HID: hid-sensor-custom: Fix big on-stack allocation in hid_sensor_custom_get_known()
struct hid_sensor_custom_properties is currently 384 bytes big, which consumes too much stack space for no good reason. Make it dynamically allocated. Fixes: 98c062e824519 ("HID: hid-sensor-custom: Allow more custom iio sensors") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
c8aca355bd
commit
f1f73651a0
@ -911,21 +911,28 @@ hid_sensor_custom_get_known(struct hid_sensor_hub_device *hsdev,
|
|||||||
int ret;
|
int ret;
|
||||||
const struct hid_sensor_custom_match *match =
|
const struct hid_sensor_custom_match *match =
|
||||||
hid_sensor_custom_known_table;
|
hid_sensor_custom_known_table;
|
||||||
struct hid_sensor_custom_properties prop;
|
struct hid_sensor_custom_properties *prop;
|
||||||
|
|
||||||
ret = hid_sensor_custom_properties_get(hsdev, &prop);
|
prop = kmalloc(sizeof(struct hid_sensor_custom_properties), GFP_KERNEL);
|
||||||
|
if (!prop)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
ret = hid_sensor_custom_properties_get(hsdev, prop);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto out;
|
||||||
|
|
||||||
while (match->tag) {
|
while (match->tag) {
|
||||||
if (hid_sensor_custom_do_match(hsdev, match, &prop)) {
|
if (hid_sensor_custom_do_match(hsdev, match, prop)) {
|
||||||
*known = match;
|
*known = match;
|
||||||
return 0;
|
ret = 0;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
match++;
|
match++;
|
||||||
}
|
}
|
||||||
|
ret = -ENODATA;
|
||||||
return -ENODATA;
|
out:
|
||||||
|
kfree(prop);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_device *
|
static struct platform_device *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user