]> git.hungrycats.org Git - linux/commitdiff
coresight: Handle errors in finding input/output ports
authorSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 11 Jul 2018 19:40:28 +0000 (13:40 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:35:09 +0000 (08:35 +0200)
[ Upstream commit fe470f5f7f684ed15bc49b6183a64237547910ff ]

If we fail to find the input / output port for a LINK component
while enabling a path, we should fail gracefully rather than
assuming port "0".

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight.c

index 93738dfbf6313ea09f9f970ce463ec8374b4f661..902ee6efd09cc8ffab8c07a9033bc7662f06a9d5 100644 (file)
@@ -86,7 +86,7 @@ static int coresight_find_link_inport(struct coresight_device *csdev)
        dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n",
                dev_name(&parent->dev), dev_name(&csdev->dev));
 
-       return 0;
+       return -ENODEV;
 }
 
 static int coresight_find_link_outport(struct coresight_device *csdev)
@@ -107,7 +107,7 @@ static int coresight_find_link_outport(struct coresight_device *csdev)
        dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n",
                dev_name(&csdev->dev), dev_name(&child->dev));
 
-       return 0;
+       return -ENODEV;
 }
 
 static int coresight_enable_sink(struct coresight_device *csdev)
@@ -155,6 +155,9 @@ static int coresight_enable_link(struct coresight_device *csdev)
        else
                refport = 0;
 
+       if (refport < 0)
+               return refport;
+
        if (atomic_inc_return(&csdev->refcnt[refport]) == 1) {
                if (link_ops(csdev)->enable) {
                        ret = link_ops(csdev)->enable(csdev, inport, outport);