stm class: Do not leak the chrdev in error path
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fri, 4 Mar 2016 14:36:10 +0000 (16:36 +0200)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 1 Jun 2016 21:42:51 +0000 (15:42 -0600)
Currently, the error path of stm_register_device() forgets to unregister
the chrdev. Fix this.

Reported-by: Alan Cox <alan.cox@intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Laurent Fert <laurent.fert@intel.com>
(cherry picked from commit cbe4a61d1ddc4790d950ca8c33ef79ee68ef5e2b)

drivers/hwtracing/stm/core.c

index a6c6b2d6a67b1fe223fb6fd6f87e29ca6c0bcc10..0ffccfdd10175e7c00129225fd48e45a9d7f4cd5 100644 (file)
@@ -688,6 +688,8 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
        return 0;
 
 err_device:
+       unregister_chrdev(stm->major, stm_data->name);
+
        /* matches device_initialize() above */
        put_device(&stm->dev);
 err_free: