otgcontrol: add synch. to device-connected sysfs prop./fix pinctrl read bug
Device-connected sysfs property is vulnerable for simultanious access by IRQ handler and sysfs property show handler. Fix bug causing kernel stack-dump/crash when trying to read current pinctrl state through sysfs propertypull/10/head
parent
914d0eaeb4
commit
fea66edaed
|
@ -339,14 +339,21 @@ static void otgcontrol_gpio_irq_work(struct work_struct *work)
|
|||
otgc_data->one_wire_gpio_state = cur_gpio_state;
|
||||
|
||||
if (otgc_data->one_wire_gpio_state ==
|
||||
OTG1_ONEWIRE_GPIO_STATE__DEVICE_CONNECTED)
|
||||
OTG1_ONEWIRE_GPIO_STATE__DEVICE_CONNECTED) {
|
||||
SYNC_SET_FLAG(otgc_data->otg1_device_connected,
|
||||
&otgc_data->lock);
|
||||
|
||||
otgcontrol_handleInput(otgc_data,
|
||||
OTG1_EVENT__DEVICE_CONNECTED,
|
||||
NULL);
|
||||
else
|
||||
}
|
||||
else {
|
||||
SYNC_CLEAR_FLAG(otgc_data->otg1_device_connected,
|
||||
&otgc_data->lock);
|
||||
otgcontrol_handleInput(otgc_data,
|
||||
OTG1_EVENT__DEVICE_DISCONNECTED,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SYNC_CLEAR_FLAG(otgc_data->one_wire_gpio_irq_is_handling,
|
||||
|
|
|
@ -59,7 +59,8 @@ static ssize_t attribute_show(struct kobject *kobj,
|
|||
dev_dbg(otgc_data->dev,
|
||||
"%s: Returning cur otg1_device_connected value (%d)\n",
|
||||
__func__,
|
||||
otgc_data->otg1_device_connected);
|
||||
SYNC_GET_FLAG(otgc_data->otg1_device_connected,
|
||||
&otgc_data->lock));
|
||||
|
||||
var = otgc_data->otg1_device_connected;
|
||||
}
|
||||
|
@ -96,12 +97,23 @@ static ssize_t attribute_show(struct kobject *kobj,
|
|||
|
||||
var = otgc_data->otg1_controllermode;
|
||||
}
|
||||
else if (strcmp(attr->attr.name, "otg1_pinctrlstate") == 0) {
|
||||
otgc_data = to_otgcontrol_data(attr,
|
||||
otg1_pinctrlstate_attribute);
|
||||
dev_dbg(otgc_data->dev,
|
||||
"%s: Returning cur pinctrlstate (%d)\n",
|
||||
__func__,
|
||||
otgc_data->otg1_pinctrlstate);
|
||||
|
||||
var = otgc_data->otg1_pinctrlstate;
|
||||
}
|
||||
else {
|
||||
dev_dbg(otgc_data->dev,
|
||||
"%s: Invalid attribute name (%s)\n",
|
||||
"%s: Invalid attribute name (%s), returning 0\n",
|
||||
__func__,
|
||||
attr->attr.name);
|
||||
return -EINVAL;
|
||||
|
||||
var = 0;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", var);
|
||||
|
|
Loading…
Reference in New Issue