From af42f432f683430df34a2a2ba084492daaae0a5c Mon Sep 17 00:00:00 2001 From: Shreshtha Sahu Date: Thu, 1 Aug 2013 16:14:59 +0530 Subject: media: video: tegra: fix miscdevice registeration name Allocate driver name string in info struct, rather than passing a pointer to a stack allocated array when registering a miscdevice. This prevents 'cat /proc/misc' from dereferencing a dangling pointer. Drivers of following devices were updated - ad5816, as364x, dw9718, imx091, max77387, max77665-flash, ov5693, ov9772, sh532u, ssl3250a and tps61050. Change-Id: I2344e6fefabdeda962ea33bc10803881e07ab3f0 Signed-off-by: Shreshtha Sahu Reviewed-on: http://git-master/r/256818 GVS: Gerrit_Virtual_Submit Reviewed-by: Kiran Adduri Reviewed-by: Bharat Nihalani Reviewed-by: Matthew Pedro --- drivers/media/video/tegra/ssl3250a.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers/media/video/tegra/ssl3250a.c') diff --git a/drivers/media/video/tegra/ssl3250a.c b/drivers/media/video/tegra/ssl3250a.c index 2656138099e6..e36d2b36dd85 100644 --- a/drivers/media/video/tegra/ssl3250a.c +++ b/drivers/media/video/tegra/ssl3250a.c @@ -1,7 +1,7 @@ /* * ssl3250a.c - ssl3250a flash/torch kernel driver * - * Copyright (C) 2011 NVIDIA Corporation. + * Copyright (C) 2011-2013 NVIDIA Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -164,6 +164,7 @@ struct ssl3250a_info { struct nvc_regulator vreg_i2c; u8 s_mode; struct ssl3250a_info *s_info; + char devname[16]; }; static struct nvc_torch_pin_state ssl3250a_default_pinstate = { @@ -900,7 +901,6 @@ static int ssl3250a_probe( const struct i2c_device_id *id) { struct ssl3250a_info *info; - char dname[16]; int err; dev_dbg(&client->dev, "%s\n", __func__); @@ -937,18 +937,19 @@ static int ssl3250a_probe( } if (info->pdata->dev_name != 0) - strcpy(dname, info->pdata->dev_name); + strncpy(info->devname, info->pdata->dev_name, + sizeof(info->devname) - 1); else - strcpy(dname, "ssl3250a"); + strncpy(info->devname, "ssl3250a", sizeof(info->devname) - 1); if (info->pdata->num) - snprintf(dname, sizeof(dname), "%s.%u", - dname, info->pdata->num); - info->miscdev.name = dname; + snprintf(info->devname, sizeof(info->devname), "%s.%u", + info->devname, info->pdata->num); + info->miscdev.name = info->devname; info->miscdev.fops = &ssl3250a_fileops; info->miscdev.minor = MISC_DYNAMIC_MINOR; if (misc_register(&info->miscdev)) { dev_err(&client->dev, "%s unable to register misc device %s\n", - __func__, dname); + __func__, info->devname); ssl3250a_del(info); return -ENODEV; } -- cgit v1.2.3