Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Nadezda Lutovinova <lutovinova@ispras.ru>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200819143756.30626-1-lutovinova@ispras.ru

authored by

Nadezda Lutovinova and committed by
Sam Ravnborg
f688a345 7f7fb53f

+10 -2
+10 -2
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
··· 310 310 const struct i2c_device_id *id) 311 311 { 312 312 struct device *dev = &stdp4028_i2c->dev; 313 + int ret; 313 314 314 - ge_b850v3_lvds_init(dev); 315 + ret = ge_b850v3_lvds_init(dev); 316 + 317 + if (ret) 318 + return ret; 315 319 316 320 ge_b850v3_lvds_ptr->stdp4028_i2c = stdp4028_i2c; 317 321 i2c_set_clientdata(stdp4028_i2c, ge_b850v3_lvds_ptr); ··· 376 372 const struct i2c_device_id *id) 377 373 { 378 374 struct device *dev = &stdp2690_i2c->dev; 375 + int ret; 379 376 380 - ge_b850v3_lvds_init(dev); 377 + ret = ge_b850v3_lvds_init(dev); 378 + 379 + if (ret) 380 + return ret; 381 381 382 382 ge_b850v3_lvds_ptr->stdp2690_i2c = stdp2690_i2c; 383 383 i2c_set_clientdata(stdp2690_i2c, ge_b850v3_lvds_ptr);