Kernel panic on drivers/regulator/core.c

Hi, I’m working with inforce6301 (Snapdragon 410(APQ8016)) and using custom linux kernel 4.14 based on linaro release 18.01
https://releases.linaro.org/96boards/dragonboard410c/linaro/debian/18.01/

I get kernel panic very rarely.
And I got the following log.
Are there any bugs about regulator in 4.14 ?

<4>[148857.924890] ------------[ cut here ]------------
<2>[148857.924907] kernel BUG at drivers/regulator/core.c:218!
<0>[148857.924916] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
<4>[148857.924923] Modules linked in: ov5640 v4l2_common venus_enc venus_dec smsc75xx msm crc32_ce tca8418_keypad lt9211 tca9534_bl xo2 si4703 ds4520_fm mm3285 ds4520_datt qcom_camss drm_kms_helper venus_core v4l2_mem2mem videobuf2_dma_sg mdt_loader v4l2_fwnode msm_rng videobuf2_memops drm rng_core videobuf2_v4l2 snd_soc_lpass_apq8016 snd_soc_msm8916_analog snd_soc_lpass_cpu snd_soc_apq8016_sbc snd_soc_msm8916_digital videobuf2_core snd_soc_lpass_platform videodev i2c_qcom_cci media lcd_stby ip_tables x_tables
<4>[148857.925032] CPU: 3 PID: 1570 Comm: kworker/3:2 Not tainted 4.14.0-qcom-ifc6301-arm64 #32
<4>[148857.925039] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
<4>[148857.925054] Workqueue: events dbs_work_handler
<4>[148857.925064] task: ffff80003c625700 task.stack: ffff00000c8b0000
<4>[148857.925076] PC is at regulator_check_voltage+0xc0/0x130
<4>[148857.925086] LR is at regulator_set_voltage_unlocked+0x60/0x278
<4>[148857.925093] pc : [<ffff000008545428>] lr : [<ffff000008545e38>] pstate: 20000145
<4>[148857.925099] sp : ffff00000c8b3b70
<4>[148857.925105] x29: ffff00000c8b3b70 x28: ffff80003c648780 
<4>[148857.925116] x27: ffff80003c6480c8 x26: ffff80003c6481c8 
<4>[148857.925127] x25: 00000000413b3800 x24: ffff80003c648080 
<4>[148857.925137] x23: 0000000000103664 x22: 0000000000103664 
<4>[148857.925147] x21: ffff80003c648780 x20: ffff80003c648780 
<4>[148857.925158] x19: ffff80003d3bc000 x18: 00000000000007e6 
<4>[148857.925168] x17: 0000ffff8473a4b0 x16: ffff000008139d40 
<4>[148857.925179] x15: 000038063e94f98b x14: 0000000000000416 
<4>[148857.925189] x13: 0000000000000000 x12: 000085ee0d4e2a47 
<4>[148857.925199] x11: 00000000000003ab x10: 0000000000000a80 
<4>[148857.925210] x9 : ffff00000c8b3d50 x8 : 0000000000000030 
<4>[148857.925220] x7 : 0000000017d78400 x6 : 0000000000000000 
<4>[148857.925230] x5 : 0000000000000000 x4 : 0000000000103664 
<4>[148857.925240] x3 : 0000000000137478 x2 : ffff00000c8b3bc8 
<4>[148857.925250] x1 : ffff00000c8b3bcc x0 : ffff80003d3bc000 
<0>[148857.925262] Process kworker/3:2 (pid: 1570, stack limit = 0xffff00000c8b0000)
<4>[148857.925269] Call trace:
<4>[148857.925276] Exception stack(0xffff00000c8b3a30 to 0xffff00000c8b3b70)
<4>[148857.925285] 3a20:                                   ffff80003d3bc000 ffff00000c8b3bcc
<4>[148857.925294] 3a40: ffff00000c8b3bc8 0000000000137478 0000000000103664 0000000000000000
<4>[148857.925304] 3a60: 0000000000000000 0000000017d78400 0000000000000030 ffff00000c8b3d50
<4>[148857.925313] 3a80: 0000000000000a80 00000000000003ab 000085ee0d4e2a47 0000000000000000
<4>[148857.925322] 3aa0: 0000000000000416 000038063e94f98b ffff000008139d40 0000ffff8473a4b0
<4>[148857.925331] 3ac0: 00000000000007e6 ffff80003d3bc000 ffff80003c648780 ffff80003c648780
<4>[148857.925341] 3ae0: 0000000000103664 0000000000103664 ffff80003c648080 00000000413b3800
<4>[148857.925350] 3b00: ffff80003c6481c8 ffff80003c6480c8 ffff80003c648780 ffff00000c8b3b70
<4>[148857.925360] 3b20: ffff000008545e38 ffff00000c8b3b70 ffff000008545428 0000000020000145
<4>[148857.925369] 3b40: 0000000000000002 ffff80003d16d340 ffffffffffffffff 00000000413b3800
<4>[148857.925377] 3b60: ffff00000c8b3b70 ffff000008545428
<4>[148857.925387] [<ffff000008545428>] regulator_check_voltage+0xc0/0x130
<4>[148857.925397] [<ffff000008546094>] regulator_set_voltage+0x44/0x78
<4>[148857.925409] [<ffff0000085c68a8>] _set_opp_voltage+0x40/0x130
<4>[148857.925420] [<ffff0000085c77b0>] dev_pm_opp_set_rate+0x2d8/0x438
<4>[148857.925430] [<ffff00000884a654>] set_target+0x44/0x70
<4>[148857.925441] [<ffff0000088441e0>] __cpufreq_driver_target+0x2c8/0x5c0
<4>[148857.925450] [<ffff000008848cd4>] od_dbs_update+0x104/0x1a0
<4>[148857.925459] [<ffff0000088498a4>] dbs_work_handler+0x3c/0x78
<4>[148857.925470] [<ffff0000080e0374>] process_one_work+0x1cc/0x328
<4>[148857.925479] [<ffff0000080e0520>] worker_thread+0x50/0x450
<4>[148857.925489] [<ffff0000080e667c>] kthread+0xfc/0x128
<4>[148857.925499] [<ffff000008084b60>] ret_from_fork+0x10/0x18
<0>[148857.925510] Code: 2a0003e4 b9000020 17fffff6 d503201f (d4210000) 
<4>[148857.925524] ---[ end trace 82b891b7bdc95ce5 ]---
<0>[148857.933187] Kernel panic - not syncing: Fatal exception
<2>[148857.933198] SMP: stopping secondary CPUs
<0>[148857.933207] Kernel Offset: disabled
<0>[148857.933215] CPU features: 0x002005
<0>[148857.933220] Memory Limit: none

This error is hit in the following BUG_ON.
drivers/regulator/core.c

/* Platform voltage constraint check */
static int regulator_check_voltage(struct regulator_dev *rdev,
				   int *min_uV, int *max_uV)
{
	BUG_ON(*min_uV > *max_uV);

	if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_VOLTAGE)) {
		rdev_err(rdev, "voltage operation not allowed\n");
		return -EPERM;
	}

	if (*max_uV > rdev->constraints->max_uV)
		*max_uV = rdev->constraints->max_uV;
	if (*min_uV < rdev->constraints->min_uV)
		*min_uV = rdev->constraints->min_uV;

	if (*min_uV > *max_uV) {
		rdev_err(rdev, "unsupportable voltage range: %d-%duV\n",
			 *min_uV, *max_uV);
		return -EINVAL;
	}

	return 0;
}

AS usual I would suggest to upgrade to latest release. Here cpufreq seems to trigger a change in the voltage (probably of a core) that is out of the defined limits (they are usually set in the device tree). So you shoudl easily identify which one is problematic.