Kernel NULL pointer dereference in tegra_camera_open

I’m trying to port my LI_M021C_MIPI camera driver to r28.1. Everything compiles and probes thanks to Shane, but nvcamerasrc/nvgstcapture fails in a strange way when I try to run it:

[  732.072014] Unable to handle kernel NULL pointer dereference at virtual address 00000050
[  732.080126] pgd = ffffffc07ce54000
[  732.083696] [00000050] *pgd=00000000fcf3a003, *pud=00000000fcf3a003, *pmd=0000000000000000
[  732.092054] Internal error: Oops: 96000046 [#1] PREEMPT SMP
[  732.097610] Modules linked in:
[  732.100663] CPU: 0 PID: 11361 Comm: nvcamera-daemon Not tainted 4.4.38+ #0
[  732.107519] Hardware name: jetson_tx1 (DT)
[  732.111602] task: ffffffc04566b200 ti: ffffffc02ec4c000 task.ti: ffffffc02ec4c000
[  732.119070] PC is at tegra_camera_open+0x24/0x5c
[  732.123674] LR is at tegra_camera_open+0x24/0x5c
[  732.128277] pc : [<ffffffc0004c2488>] lr : [<ffffffc0004c2488>] pstate: 20000145
[  732.135652] sp : ffffffc02ec4fb50
[  732.138954] x29: ffffffc02ec4fb50 x28: 0000000000000000
[  732.144263] x27: 0000000000000026 x26: ffffffc02a064900
[  732.149572] x25: 0000000000000000 x24: ffffffc02a064910
[  732.154881] x23: ffffffc000ba63a0 x22: ffffffc02a064900
[  732.160190] x21: ffffffc0f9dd24d8 x20: 000000000000003c
[  732.165498] x19: 0000000000000000 x18: 0000000000000011
[  732.170807] x17: 0000007f79883250 x16: ffffffc0001c225c
[  732.176116] x15: 0000007f7a261cc0 x14: 0000000000000000
[  732.181425] x13: ffffffffffffffff x12: 0000000000000005
[  732.186735] x11: 000000000000000a x10: fefefefefefefeff
[  732.192044] x9 : 0000000000000000 x8 : ffffffc0d148dbb0
[  732.197352] x7 : 0000000000000000 x6 : 0000000000000000
[  732.202660] x5 : 0000000000000000 x4 : ffffffc02ec4c000
[  732.207968] x3 : 0000000000000000 x2 : 0000000000000000
[  732.213276] x1 : 0000000000000001 x0 : ffffffc00150a238

[  732.220068] Process nvcamera-daemon (pid: 11361, stack limit = 0xffffffc02ec4c020)
[  732.227617] Call trace:
[  732.230055] [<ffffffc0004c2488>] tegra_camera_open+0x24/0x5c
[  732.235700] [<ffffffc00055a300>] misc_open+0x160/0x1c4
[  732.240825] [<ffffffc0001c7368>] chrdev_open+0xfc/0x1b4
[  732.246036] [<ffffffc0001c0d4c>] do_dentry_open+0x1fc/0x310
[  732.251593] [<ffffffc0001c1ddc>] vfs_open+0x68/0x78
[  732.256457] [<ffffffc0001cff7c>] do_last+0x540/0x698
[  732.261406] [<ffffffc0001d01a4>] path_openat+0xd0/0x140
[  732.266615] [<ffffffc0001d255c>] do_filp_open+0x38/0x8c
[  732.271825] [<ffffffc0001c219c>] do_sys_open+0x178/0x214
[  732.277122] [<ffffffc0001c226c>] SyS_openat+0x10/0x18
[  732.282161] [<ffffffc0000847f0>] el0_svc_naked+0x24/0x28
[  732.287458] ---[ end trace 0d6f9e2bb5ec5839 ]---

The code doesn’t even get to my driver, it fails in tegra_camera_open from a null pointer dereference. I’m assuming there’s some subsystem I forgot to register with.

That function is located at 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);
        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);

        /* 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
}

Anyone else run into this issue?

@Atrer
That’s must be something wrong in your device tree cause the nvcamera-daemon crash.

Hi Atrer,

Have you clarified the cause and resolved the problem?
Any further information can be shared?

Thanks

I’m also getting the same error when trying to bring up a new camera driver for the IMX214. Any help would be appreciated. I’ve created a more in-depth post here:

[url]https://devtalk.nvidia.com/default/topic/1036366/jetson-tx1/imx214-bringup-on-tx1-28-2/[/url]