diff options
author | Shreshtha Sahu <ssahu@nvidia.com> | 2013-08-01 16:14:59 +0530 |
---|---|---|
committer | Matthew Pedro <mapedro@nvidia.com> | 2013-08-07 10:09:49 -0700 |
commit | af42f432f683430df34a2a2ba084492daaae0a5c (patch) | |
tree | 8fa47c7ce091efab1add28f0eca6d34961dfc4ee /drivers/media/video/tegra/ov9772.c | |
parent | b358015d5dc66e1c2de23f68aeb6b53d485f1365 (diff) |
media: video: tegra: fix miscdevice registeration nametegra-l4t-r17.1tegra-l4t-r17-17r1
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 <ssahu@nvidia.com>
Reviewed-on: http://git-master/r/256818
GVS: Gerrit_Virtual_Submit
Reviewed-by: Kiran Adduri <kadduri@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>
Diffstat (limited to 'drivers/media/video/tegra/ov9772.c')
-rw-r--r-- | drivers/media/video/tegra/ov9772.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/media/video/tegra/ov9772.c b/drivers/media/video/tegra/ov9772.c index 9a312b8c489b..f8797c521316 100644 --- a/drivers/media/video/tegra/ov9772.c +++ b/drivers/media/video/tegra/ov9772.c @@ -201,6 +201,7 @@ struct ov9772_info { u8 i2c_buf[OV9772_SIZEOF_I2C_BUF]; u8 bin_en; struct nvc_fuseid fuse_id; + char devname[16]; }; struct ov9772_reg { @@ -2198,7 +2199,6 @@ static int ov9772_probe( const struct i2c_device_id *id) { struct ov9772_info *info; - char dname[16]; unsigned long clock_probe_rate; int err; @@ -2261,18 +2261,19 @@ static int ov9772_probe( info->pdata->probe_clock(0); } 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, "ov9772"); + strncpy(info->devname, "ov9772", 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 = &ov9772_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); ov9772_del(info); return -ENODEV; } |