linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] coresight: etm3x: Smatch: Fix potential NULL pointer dereference
@ 2019-06-13 10:06 Suzuki K Poulose
  2019-06-13 10:06 ` [PATCH 2/2] coresight: tmc: " Suzuki K Poulose
  2019-06-17 19:28 ` [PATCH 1/2] coresight: etm3x: " Mathieu Poirier
  0 siblings, 2 replies; 4+ messages in thread
From: Suzuki K Poulose @ 2019-06-13 10:06 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: coresight, Dan Carpenter, mathieu.poirier, Suzuki K Poulose

Based on the following report from  Smatch tool, make sure we have a
valid drvdata before we dereference it to find the real dev.

The patch 21d26b905c05: "coresight: etm: Clean up device specific
data" from May 22, 2019, leads to the following Smatch complaint:

    ./drivers/hwtracing/coresight/coresight-etm3x.c:460 etm_get_trace_id()
    warn: variable dereferenced before check 'drvdata' (see line 458)

./drivers/hwtracing/coresight/coresight-etm3x.c
   457		int trace_id = -1;
   458		struct device *etm_dev = drvdata->csdev->dev.parent;
                                         ^^^^^^^^^
New dereference

   459
   460		if (!drvdata)
                    ^^^^^^^^
Checked too late.  Delete the check?

   461			goto out;
   462

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/coresight-etm3x.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c
index bed7291..225c298 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x.c
@@ -455,11 +455,12 @@ int etm_get_trace_id(struct etm_drvdata *drvdata)
 {
 	unsigned long flags;
 	int trace_id = -1;
-	struct device *etm_dev = drvdata->csdev->dev.parent;
+	struct device *etm_dev;
 
 	if (!drvdata)
 		goto out;
 
+	etm_dev = drvdata->csdev->dev.parent;
 	if (!local_read(&drvdata->mode))
 		return drvdata->traceid;
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH 0/2] coresight: next v5.2-rc5 (Part 2)
@ 2019-06-21 17:52 Mathieu Poirier
  2019-06-21 17:52 ` [PATCH 2/2] coresight: tmc: Smatch: Fix potential NULL pointer dereference Mathieu Poirier
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Poirier @ 2019-06-21 17:52 UTC (permalink / raw)
  To: gregkh; +Cc: linux-arm-kernel

Good morning,

As requested these are two patches that were part of the original tally[1]
that should go on your char-misc-next for the 5.3 cycle.

Applies cleanly on char-misc-next (1a044213fc64).

Thanks,
Mathieu

[1]. https://www.spinics.net/lists/arm-kernel/msg736135.html 

Suzuki K Poulose (2):
  coresight: etm3x: Smatch: Fix potential NULL pointer dereference
  coresight: tmc: Smatch: Fix potential NULL pointer dereference

 drivers/hwtracing/coresight/coresight-etm3x.c   | 3 ++-
 drivers/hwtracing/coresight/coresight-tmc-etr.c | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-21 17:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 10:06 [PATCH 1/2] coresight: etm3x: Smatch: Fix potential NULL pointer dereference Suzuki K Poulose
2019-06-13 10:06 ` [PATCH 2/2] coresight: tmc: " Suzuki K Poulose
2019-06-17 19:28 ` [PATCH 1/2] coresight: etm3x: " Mathieu Poirier
2019-06-21 17:52 [PATCH 0/2] coresight: next v5.2-rc5 (Part 2) Mathieu Poirier
2019-06-21 17:52 ` [PATCH 2/2] coresight: tmc: Smatch: Fix potential NULL pointer dereference Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).