The following source is from:
kernel-4.4/drivers/video/tegra/camera/tegra_camera_platform.c
static int tegra_camera_open(struct inode *inode, struct file *file)
{
struct tegra_camera_info *info;
struct miscdevice *mdev;
mdev = file->private_data;
info = dev_get_drvdata(mdev->parent); // <b>info is NULL here</b>
file->private_data = info;
#if defined(CONFIG_TEGRA_BWMGR)
/* get bandwidth manager handle if needed */
info->bwmgr_handle =
tegra_bwmgr_register(TEGRA_BWMGR_CLIENT_CAMERA); // <b>NULL dereference causes crash</b>
/* set the initial rate */
if (IS_ERR_OR_NULL(info->bwmgr_handle)) {
info->bwmgr_handle = NULL;
return -ENODEV;
}
tegra_bwmgr_set_emc(info->bwmgr_handle, 0,
TEGRA_BWMGR_SET_EMC_SHARED_BW);
return 0;
#else
return tegra_camera_emc_clk_enable();
#endif
}
I have an issue where dev_get_drvdata(mdev->parent) is returning NULL for tegra_camera_info. This causes info->bwmgr_handle to dereference NULL and crash.
I have only noticed this on the TX1, not the TX2. As a fix I’m just skipping the “CONFIG_TEGRA_BWMGR” stuff and pretending like it’s not set.
This is presenting in a custom camera driver. Is there some place I need to set that data so it can get retrieved by dev_get_drvdata?