Skip to content

Commit 4d5ae23

Browse files
committed
Merge tag 'auxdisplay-for-linus-v5.17-rc7' of git://github.com/ojeda/linux
Pull auxdisplay fixes from Miguel Ojeda: "A few lcd2s fixes from Andy Shevchenko" * tag 'auxdisplay-for-linus-v5.17-rc7' of git://github.com/ojeda/linux: auxdisplay: lcd2s: Use proper API to free the instance of charlcd object auxdisplay: lcd2s: Fix memory leak in ->remove() auxdisplay: lcd2s: Fix lcd2s_redefine_char() feature
2 parents 5859a2b + 9ed331f commit 4d5ae23

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

drivers/auxdisplay/lcd2s.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static int lcd2s_redefine_char(struct charlcd *lcd, char *esc)
238238
if (buf[1] > 7)
239239
return 1;
240240

241-
i = 0;
241+
i = 2;
242242
shift = 0;
243243
value = 0;
244244
while (*esc && i < LCD2S_CHARACTER_SIZE + 2) {
@@ -298,6 +298,10 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c,
298298
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA))
299299
return -EIO;
300300

301+
lcd2s = devm_kzalloc(&i2c->dev, sizeof(*lcd2s), GFP_KERNEL);
302+
if (!lcd2s)
303+
return -ENOMEM;
304+
301305
/* Test, if the display is responding */
302306
err = lcd2s_i2c_smbus_write_byte(i2c, LCD2S_CMD_DISPLAY_OFF);
303307
if (err < 0)
@@ -307,12 +311,6 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c,
307311
if (!lcd)
308312
return -ENOMEM;
309313

310-
lcd2s = kzalloc(sizeof(struct lcd2s_data), GFP_KERNEL);
311-
if (!lcd2s) {
312-
err = -ENOMEM;
313-
goto fail1;
314-
}
315-
316314
lcd->drvdata = lcd2s;
317315
lcd2s->i2c = i2c;
318316
lcd2s->charlcd = lcd;
@@ -321,26 +319,24 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c,
321319
err = device_property_read_u32(&i2c->dev, "display-height-chars",
322320
&lcd->height);
323321
if (err)
324-
goto fail2;
322+
goto fail1;
325323

326324
err = device_property_read_u32(&i2c->dev, "display-width-chars",
327325
&lcd->width);
328326
if (err)
329-
goto fail2;
327+
goto fail1;
330328

331329
lcd->ops = &lcd2s_ops;
332330

333331
err = charlcd_register(lcd2s->charlcd);
334332
if (err)
335-
goto fail2;
333+
goto fail1;
336334

337335
i2c_set_clientdata(i2c, lcd2s);
338336
return 0;
339337

340-
fail2:
341-
kfree(lcd2s);
342338
fail1:
343-
kfree(lcd);
339+
charlcd_free(lcd2s->charlcd);
344340
return err;
345341
}
346342

@@ -349,7 +345,7 @@ static int lcd2s_i2c_remove(struct i2c_client *i2c)
349345
struct lcd2s_data *lcd2s = i2c_get_clientdata(i2c);
350346

351347
charlcd_unregister(lcd2s->charlcd);
352-
kfree(lcd2s->charlcd);
348+
charlcd_free(lcd2s->charlcd);
353349
return 0;
354350
}
355351

0 commit comments

Comments
 (0)