未验证 提交 ce410900 编写于 作者: A Axel Lin 提交者: Mark Brown

regulator: cros-ec-regulator: Add NULL test for devm_kmemdup call

Fix possible NULL pointer dereference.
Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20200802032509.305425-1-axel.lin@ingics.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 bcb3b2a7
......@@ -170,6 +170,9 @@ static int cros_ec_regulator_init_info(struct device *dev,
data->voltages_mV =
devm_kmemdup(dev, resp.voltages_mv,
sizeof(u16) * data->num_voltages, GFP_KERNEL);
if (!data->voltages_mV)
return -ENOMEM;
data->desc.n_voltages = data->num_voltages;
/* Make sure the returned name is always a valid string */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册