[RFC PATCH v4 1/2] dtc: protect against null pointer dereference in srcpos_string()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



From: Frank Rowand <frank.rowand@xxxxxxxxxxxxxx>

Check for NULL pos before dereferencing is in srcpos_string().

Signed-off-by: Frank Rowand <frank.rowand@xxxxxxxxxxxxxx>
---
 srcpos.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: b/srcpos.c
===================================================================
--- a/srcpos.c
+++ b/srcpos.c
@@ -272,7 +272,9 @@ srcpos_string(struct srcpos *pos)
 		fname = pos->file->name;
 
 
-	if (pos->first_line != pos->last_line)
+	if (!pos)
+		rc = asprintf(&pos_str, "%s:0", fname);
+	else if (pos->first_line != pos->last_line)
 		rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
 			      pos->first_line, pos->first_column,
 			      pos->last_line, pos->last_column);
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux