Skip to content

Commit dc689cd

Browse files
Nadezda Lutovinovagregkh
authored andcommitted
drm/brige/megachips: Add checking if ge_b850v3_lvds_init() is working correctly
[ Upstream commit f688a34 ] 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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c1918dd commit dc689cd

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,12 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client *stdp4028_i2c,
302302
const struct i2c_device_id *id)
303303
{
304304
struct device *dev = &stdp4028_i2c->dev;
305+
int ret;
306+
307+
ret = ge_b850v3_lvds_init(dev);
305308

306-
ge_b850v3_lvds_init(dev);
309+
if (ret)
310+
return ret;
307311

308312
ge_b850v3_lvds_ptr->stdp4028_i2c = stdp4028_i2c;
309313
i2c_set_clientdata(stdp4028_i2c, ge_b850v3_lvds_ptr);
@@ -361,8 +365,12 @@ static int stdp2690_ge_b850v3_fw_probe(struct i2c_client *stdp2690_i2c,
361365
const struct i2c_device_id *id)
362366
{
363367
struct device *dev = &stdp2690_i2c->dev;
368+
int ret;
369+
370+
ret = ge_b850v3_lvds_init(dev);
364371

365-
ge_b850v3_lvds_init(dev);
372+
if (ret)
373+
return ret;
366374

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

0 commit comments

Comments
 (0)