From 46fe66a7c8557418e3ed919c033c01f05d16457e Mon Sep 17 00:00:00 2001 From: Pratik Patel Date: Sun, 2 Dec 2012 20:33:50 -0800 Subject: [PATCH] coresight: return error if null or error is passed to coresight_register Fail coresight_register if invalid (error or null) argument is passed to avoid crashes. Change-Id: I6c39ba2b81333f24480fdf5b348934651e095be5 Signed-off-by: Pratik Patel --- drivers/coresight/coresight.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/coresight/coresight.c b/drivers/coresight/coresight.c index 3974f2ea37b2..39bc9ffe2726 100644 --- a/drivers/coresight/coresight.c +++ b/drivers/coresight/coresight.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -566,6 +566,9 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) struct coresight_device *csdev; struct coresight_connection *conns; + if (IS_ERR_OR_NULL(desc)) + return ERR_PTR(-EINVAL); + csdev = kzalloc(sizeof(*csdev), GFP_KERNEL); if (!csdev) { ret = -ENOMEM;