Skip to content

Commit 9ed331f

Browse files
andy-shevojeda
authored andcommitted
auxdisplay: lcd2s: Use proper API to free the instance of charlcd object
While it might work, the current approach is fragile in a few ways: - whenever members in the structure are shuffled, the pointer will be wrong - the resource freeing may include more than covered by kfree() Fix this by using charlcd_free() call instead of kfree(). Fixes: 8c9108d ("auxdisplay: add a driver for lcd2s character display") Cc: Lars Poeschel <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 898c0a1 commit 9ed331f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/auxdisplay/lcd2s.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int lcd2s_i2c_probe(struct i2c_client *i2c,
336336
return 0;
337337

338338
fail1:
339-
kfree(lcd);
339+
charlcd_free(lcd2s->charlcd);
340340
return err;
341341
}
342342

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

347347
charlcd_unregister(lcd2s->charlcd);
348-
kfree(lcd2s->charlcd);
348+
charlcd_free(lcd2s->charlcd);
349349
return 0;
350350
}
351351

0 commit comments

Comments
 (0)