coresight: coresight_unregister() function cleanup
authorMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 2 Feb 2016 21:13:57 +0000 (14:13 -0700)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 1 Jun 2016 21:30:03 +0000 (15:30 -0600)
In its current form the code never frees csdev->refcnt allocated
in coresight_register().  There is also a problem with csdev->conns
that is freed before device_unregister() rather than in the device
release function.

This patch addresses both issues by moving kfree(csdev->conns) to
coresight_device_release() and freeing csdev->refcnt, also in
the same function.

Reported-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit fae54158792aec705620bdc3938d342879204f0c)

drivers/hwtracing/coresight/coresight.c

index 41b42018b660e34505c33859097f1520abb85ca5..8872db4410ebf5b38dbfcf21eb84b01d3fd6a746 100644 (file)
@@ -481,6 +481,8 @@ static void coresight_device_release(struct device *dev)
 {
        struct coresight_device *csdev = to_coresight_device(dev);
 
+       kfree(csdev->conns);
+       kfree(csdev->refcnt);
        kfree(csdev);
 }
 
@@ -713,7 +715,6 @@ EXPORT_SYMBOL_GPL(coresight_register);
 
 void coresight_unregister(struct coresight_device *csdev)
 {
-       kfree(csdev->conns);
        device_unregister(&csdev->dev);
 }
 EXPORT_SYMBOL_GPL(coresight_unregister);