coresight: Fix csdev connections initialisation
authorSuzuki K Poulose <suzuki.poulose@arm.com>
Tue, 21 Jun 2016 16:10:50 +0000 (17:10 +0100)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 6 Sep 2016 14:24:32 +0000 (08:24 -0600)
commit47b0969652bdd1d0c2869373bd45ae3f2bbaa5af
treef306c1c048e358dafa8009d165b563c2cf72311f
parent3c0435cf30238e3658b88f4678d313416ee50c10
coresight: Fix csdev connections initialisation

This is a cleanup patch.

coresight_device->conns holds an array to point to the devices
connected to the OUT ports of a component. Sinks, e.g ETR, do not
have an OUT port (nr_outport = 0), as it streams the trace to
memory via AXI.

At coresight_register() we do :

conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL);
if (!conns) {
ret = -ENOMEM;
goto err_kzalloc_conns;
}

For ETR, since the total size requested for kcalloc is zero, the return
value is, ZERO_SIZE_PTR ( != NULL). Hence, csdev->conns = ZERO_SIZE_PTR
which cannot be verified later to contain a valid pointer. The code which
accesses the csdev->conns is bounded by the csdev->nr_outport check,
hence we don't try to dereference the ZERO_SIZE_PTR. This patch cleans
up the csdev->conns initialisation to make sure we initialise it
properly(i.e, either NULL or valid conns array).

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>
drivers/hwtracing/coresight/coresight.c
This page took 0.03713 seconds and 5 git commands to generate.