-
Notifications
You must be signed in to change notification settings - Fork 35
Description
There is a bug in the handling of the class pointer in cdevice_init(): when local_class_p already exists (for the second or subsequent channels), the code does not assign this class pointer to pchannel_p->class_p, leaving pchannel_p->class_p uninitialized (garbage value). As a result, device_create(pchannel_p->class_p, …) fails, appearing in the log as "unable to create the device."
When local_class_p is not NULL (i.e., the class has already been created), the code does not execute pchannel_p->class_p = local_class_p;. As a result, subsequent uses of pchannel_p->class_p (in device_create() / device_destroy()) operate on an uninitialized value, causing device_create() to fail.
Minimal fix patch
Move pchannel_p->class_p = local_class_p; outside the if statement to ensure that each channel holds a valid class pointer.