@@ -911,11 +911,11 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
g_hwcursor = 0;
} else {
if (!g_fbmode[0]) {
- g_fbmode[0] = opt;
+ g_fbmode[0] = kstrdup(opt, GFP_KERNEL); // ignore errors
dev_info(&sm750_dev->pdev->dev,
"find fbmode0 : %s\n", g_fbmode[0]);
} else if (!g_fbmode[1]) {
- g_fbmode[1] = opt;
+ g_fbmode[1] = kstrdup(opt, GFP_KERNEL); // ignore errors
dev_info(&sm750_dev->pdev->dev,
"find fbmode1 : %s\n", g_fbmode[1]);
} else {
@@ -1182,7 +1182,14 @@ module_init(lynxfb_init);
static void __exit lynxfb_exit(void)
{
+ size_t i = ARRAY_SIZE(g_fbmode);
+
pci_unregister_driver(&lynxfb_driver);
+
+ while (i) {
+ --i;
+ kfree(g_fbmode[i]);
+ }
kfree(g_settings);
}
module_exit(lynxfb_exit);
Assume that the driver does not own the option string or its substrings and hence duplicate the option stringis for the video mode. Allocate each copy's memory with kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> --- drivers/staging/sm750fb/sm750.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)