tegra_camera_open NULL dereference in TX1 r28.1

The following source is from:

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;

	/* 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,
	return 0;
	return tegra_camera_emc_clk_enable();

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?

Possibly related, tegra_camera_platform also fails to probe:

[    0.514800] tegra_camera_platform tegra-camera-platform: tegra_camera_probe:camera_platform_driver probe
[    0.515014] misc tegra_camera_ctrl: tegra_camera_isomgr_register: some fields not in DT.
[    0.515053] misc tegra_camera_ctrl: bits_per_pixel is invalid
[    0.515740] display board info: id 0xffff, fab 0x0
[    0.515789] panel_select fail by _node_status
[    0.516491] misc tegra_camera_ctrl: tegra_camera_probe: failed to register CAMERA as isomgr client
[    0.516542] tegra_camera_platform: probe of tegra-camera-platform failed with error -12

I had forgotten all the settings in the DTSI. Added them for the TX2, but forgot to also add them for the TX1.

Now I just need to figure out how to set all of them correctly rather than use the defaults

tegra-camera-platform {
    compatible = "nvidia, tegra-camera-platform"
    num_csi_lanes = <2>;
    max_lane_speed = <445500000>;
    min_bits_per_pixel = <10>;
    vi_peak_byte_per_pixel = <2>;
    vi_bw_margin_pct = <25>;
    max_pixel_rate = <750000>;
    isp_peak_byte_per_pixel = <2>;
    isp_bw_margin_pct = <25>