Skip to content

Bug in cdevice_init() for the second or subsequent channels #14

@dongyuetj

Description

@dongyuetj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions