• Thomas Gleixner's avatar
    Driver-core: Fix bogus 0 error return in device_add() · e6309e75
    Thomas Gleixner authored
    If device_add() is called with a device which does not have dev->p set
    up, then device_private_init() is called. If that succeeds, then the
    error variable is set to 0. Now if the dev_name(dev) check further
    down fails, then device_add() correctly terminates, but returns 0.
    That of course lets the driver progress. If later another driver uses
    this half set up device as parent then device_add() of the child
    device explodes and renders sysfs completely unusable.
    
    Set the error to -EINVAL if dev_name() check fails.
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Cc: Kay Sievers <kay.sievers@vrfy.org>
    Cc: "Hans J. Koch" <hjk@linutronix.de>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    e6309e75
core.c 43.7 KB