forked from Minki/linux
staging: fbtft: core: Don't set device platform_data
Pass platform_data as an argument to fbtft_framebuffer_alloc() instead of using dev->platform_data. This fixes an issue where the device comes from Device Tree and fbtft_probe_common() sets dev->platform_data to allocated memory. When the module is reloaded, dev->platform_data points to freed memory. Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bc7ac43253
commit
ad6d8812aa
@ -677,13 +677,13 @@ static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
|
||||
*
|
||||
*/
|
||||
struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
struct device *dev)
|
||||
struct device *dev,
|
||||
struct fbtft_platform_data *pdata)
|
||||
{
|
||||
struct fb_info *info;
|
||||
struct fbtft_par *par;
|
||||
struct fb_ops *fbops = NULL;
|
||||
struct fb_deferred_io *fbdefio = NULL;
|
||||
struct fbtft_platform_data *pdata = dev->platform_data;
|
||||
u8 *vmem = NULL;
|
||||
void *txbuf = NULL;
|
||||
void *buf = NULL;
|
||||
@ -828,7 +828,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
|
||||
par = info->par;
|
||||
par->info = info;
|
||||
par->pdata = dev->platform_data;
|
||||
par->pdata = pdata;
|
||||
par->debug = display->debug;
|
||||
par->buf = buf;
|
||||
spin_lock_init(&par->dirty_lock);
|
||||
@ -1265,12 +1265,11 @@ EXPORT_SYMBOL(fbtft_init_display);
|
||||
*/
|
||||
static int fbtft_verify_gpios(struct fbtft_par *par)
|
||||
{
|
||||
struct fbtft_platform_data *pdata;
|
||||
struct fbtft_platform_data *pdata = par->pdata;
|
||||
int i;
|
||||
|
||||
fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__);
|
||||
|
||||
pdata = par->info->device->platform_data;
|
||||
if (pdata->display.buswidth != 9 && par->startbyte == 0 &&
|
||||
par->gpio.dc < 0) {
|
||||
dev_err(par->info->device,
|
||||
@ -1388,10 +1387,9 @@ int fbtft_probe_common(struct fbtft_display *display,
|
||||
pdata = fbtft_probe_dt(dev);
|
||||
if (IS_ERR(pdata))
|
||||
return PTR_ERR(pdata);
|
||||
dev->platform_data = pdata;
|
||||
}
|
||||
|
||||
info = fbtft_framebuffer_alloc(display, dev);
|
||||
info = fbtft_framebuffer_alloc(display, dev, pdata);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -264,8 +264,9 @@ struct fbtft_par {
|
||||
/* fbtft-core.c */
|
||||
extern void fbtft_dbg_hex(const struct device *dev,
|
||||
int groupsize, void *buf, size_t len, const char *fmt, ...);
|
||||
extern struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
struct device *dev);
|
||||
struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
|
||||
struct device *dev,
|
||||
struct fbtft_platform_data *pdata);
|
||||
extern void fbtft_framebuffer_release(struct fb_info *info);
|
||||
extern int fbtft_register_framebuffer(struct fb_info *fb_info);
|
||||
extern int fbtft_unregister_framebuffer(struct fb_info *fb_info);
|
||||
|
@ -379,7 +379,7 @@ static int flexfb_probe_common(struct spi_device *sdev,
|
||||
fbtft_init_dbg(dev, "regwidth = %d\n", regwidth);
|
||||
fbtft_init_dbg(dev, "buswidth = %d\n", buswidth);
|
||||
|
||||
info = fbtft_framebuffer_alloc(&flex_display, dev);
|
||||
info = fbtft_framebuffer_alloc(&flex_display, dev, dev->platform_data);
|
||||
if (!info)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user