Commit f688a345 authored by Nadezda Lutovinova's avatar Nadezda Lutovinova Committed by Sam Ravnborg
Browse files

drm/brige/megachips: Add checking if ge_b850v3_lvds_init() is working correctly



If ge_b850v3_lvds_init() does not allocate memory for ge_b850v3_lvds_ptr,
then a null pointer dereference is accessed.

The patch adds checking of the return value of ge_b850v3_lvds_init().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: default avatarNadezda Lutovinova <lutovinova@ispras.ru>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200819143756.30626-1-lutovinova@ispras.ru
parent 7f7fb53f
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -310,8 +310,12 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client *stdp4028_i2c,
				       const struct i2c_device_id *id)
{
	struct device *dev = &stdp4028_i2c->dev;
	int ret;

	ret = ge_b850v3_lvds_init(dev);

	ge_b850v3_lvds_init(dev);
	if (ret)
		return ret;

	ge_b850v3_lvds_ptr->stdp4028_i2c = stdp4028_i2c;
	i2c_set_clientdata(stdp4028_i2c, ge_b850v3_lvds_ptr);
@@ -372,8 +376,12 @@ static int stdp2690_ge_b850v3_fw_probe(struct i2c_client *stdp2690_i2c,
				       const struct i2c_device_id *id)
{
	struct device *dev = &stdp2690_i2c->dev;
	int ret;

	ret = ge_b850v3_lvds_init(dev);

	ge_b850v3_lvds_init(dev);
	if (ret)
		return ret;

	ge_b850v3_lvds_ptr->stdp2690_i2c = stdp2690_i2c;
	i2c_set_clientdata(stdp2690_i2c, ge_b850v3_lvds_ptr);