@@ -1167,7 +1167,7 @@ static struct pci_driver lynxfb_driver = {
static int __init lynxfb_init(void)
{
- char *option;
+ const char *option;
if (fb_modesetting_disabled("sm750fb"))
return -ENODEV;
@@ -926,7 +926,7 @@ static int acornfb_probe(struct platform_device *dev)
unsigned long size;
u_int h_sync, v_sync;
int rc, i;
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("acornfb", &option))
return -ENODEV;
@@ -3546,7 +3546,7 @@ static int __init amifb_probe(struct platform_device *pdev)
u_int defmode;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("amifb", &option)) {
amifb_video_off();
@@ -1186,7 +1186,7 @@ static int __init arkfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("arkfb"))
@@ -2999,7 +2999,7 @@ static int __init atafb_probe(struct platform_device *pdev)
int pad, detected_mode, error;
unsigned int defmode = 0;
unsigned long mem_req;
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("atafb", &option))
return -ENODEV;
@@ -2514,7 +2514,7 @@ static int __maybe_unused aty128_pci_resume(struct device *dev)
static int aty128fb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("aty128fb"))
@@ -3970,7 +3970,7 @@ static int __init atyfb_init(void)
{
int err1 = 1, err2 = 1;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("atyfb"))
@@ -2616,7 +2616,7 @@ static int __init radeonfb_setup (const char *options)
static int __init radeonfb_init (void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("radeonfb"))
@@ -366,7 +366,7 @@ static const struct fb_ops au1100fb_ops =
static int au1100fb_setup(struct au1100fb_device *fbdev)
{
- char *options;
+ const char *options;
struct option_iter iter;
const char *this_opt;
int num_panels = ARRAY_SIZE(known_lcd_panels);
@@ -1578,7 +1578,7 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
static int au1200fb_setup(struct au1200fb_platdata *pd)
{
- char *options = NULL;
+ const char *options = NULL;
struct option_iter iter;
const char *this_opt;
char *endptr;
@@ -2369,7 +2369,7 @@ static int __init cirrusfb_init(void)
int error = 0;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("cirrusfb"))
@@ -1004,7 +1004,7 @@ static int __init control_of_init(struct device_node *dp)
static int __init control_init(void)
{
struct device_node *dp;
- char *option = NULL;
+ const char *option = NULL;
int ret = -ENXIO;
if (fb_get_options("controlfb", &option))
@@ -28,12 +28,9 @@
* (video=<name>:<options>)
* @option: the option will be stored here
*
- * The caller owns the string returned in @option and is
- * responsible for releasing the memory.
- *
* NOTE: Needed to maintain backwards compatibility
*/
-int fb_get_options(const char *name, char **option)
+int fb_get_options(const char *name, const char **option)
{
const char *options = NULL;
bool is_of = false;
@@ -49,12 +46,8 @@ int fb_get_options(const char *name, char **option)
enabled = false;
}
- if (option) {
- if (options)
- *option = kstrdup(options, GFP_KERNEL);
- else
- *option = NULL;
- }
+ if (option)
+ *option = options;
return enabled ? 0 : 1; // 0 on success, 1 otherwise
}
@@ -620,7 +620,6 @@ int fb_find_mode(struct fb_var_screeninfo *var,
const struct fb_videomode *default_mode,
unsigned int default_bpp)
{
- char *mode_option_buf = NULL;
int i;
/* Set up defaults */
@@ -636,10 +635,8 @@ int fb_find_mode(struct fb_var_screeninfo *var,
default_bpp = 8;
/* Did the user specify a video mode? */
- if (!mode_option) {
- fb_get_options(NULL, &mode_option_buf);
- mode_option = mode_option_buf;
- }
+ if (!mode_option)
+ fb_get_options(NULL, &mode_option);
if (mode_option) {
const char *name = mode_option;
unsigned int namelen = strlen(name);
@@ -718,7 +715,6 @@ int fb_find_mode(struct fb_var_screeninfo *var,
res_specified = 1;
}
done:
- kfree(mode_option_buf);
if (cvt) {
struct fb_videomode cvt_mode;
int ret;
@@ -1877,7 +1877,7 @@ static int __init cyber2000fb_init(void)
int ret = -1, err;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("CyberPro"))
@@ -366,7 +366,7 @@ static int efifb_probe(struct platform_device *dev)
unsigned int size_vmode;
unsigned int size_remap;
unsigned int size_total;
- char *option = NULL;
+ const char *option = NULL;
efi_memory_desc_t md;
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled)
@@ -464,7 +464,7 @@ static int ep93xxfb_probe(struct platform_device *pdev)
struct fb_info *info;
struct ep93xx_fbi *fbi;
struct resource *res;
- char *video_mode;
+ const char *video_mode;
int err;
if (!mach_info)
@@ -315,7 +315,7 @@ static int __init fm2fb_setup(const char *options)
static int __init fm2fb_init(void)
{
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("fm2fb", &option))
return -ENODEV;
@@ -1908,7 +1908,7 @@ static int __init fsl_diu_init(void)
#endif
int ret;
#ifndef MODULE
- char *option;
+ const char *option;
/*
* For kernel boot options (in 'video=xxxfb:<options>' format)
@@ -1125,7 +1125,7 @@ static int gbefb_probe(struct platform_device *p_dev)
struct fb_info *info;
struct gbefb_par *par;
#ifndef MODULE
- char *options = NULL;
+ const char *options = NULL;
#endif
info = framebuffer_alloc(sizeof(struct gbefb_par), &p_dev->dev);
@@ -445,7 +445,7 @@ static struct pci_driver gx1fb_driver = {
static int __init gx1fb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("gx1fb"))
@@ -517,7 +517,7 @@ static int __init gxfb_setup(const char *options)
static int __init gxfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("gxfb"))
@@ -653,7 +653,7 @@ static int __init lxfb_setup(const char *options)
static int __init lxfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("lxfb"))
@@ -334,7 +334,8 @@ static int grvga_probe(struct platform_device *dev)
unsigned long physical_start = 0;
unsigned long grvga_mem_size = 0;
struct grvga_par *par = NULL;
- char *options = NULL, *mode_opt = NULL;
+ const char *options = NULL;
+ const *mode_opt = NULL;
struct option_iter iter;
const char *this_opt;
@@ -780,7 +780,7 @@ static struct pci_driver gxt4500_driver = {
static int gxt4500_init(void)
{
#ifndef MODULE
- char *options;
+ const char *options;
#endif
if (fb_modesetting_disabled("gxt4500"))
@@ -903,7 +903,7 @@ static const struct fb_ops hvfb_ops = {
static void hvfb_get_option(struct fb_info *info)
{
struct hvfb_par *par = info->par;
- char *options = NULL;
+ const char *options = NULL;
char *optbuf, *opt, *p;
uint x = 0, y = 0;
@@ -1294,7 +1294,7 @@ static int __init i740fb_setup(const char *options)
static int __init i740fb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("i740fb"))
@@ -2155,7 +2155,7 @@ static void i810fb_remove_pci(struct pci_dev *dev)
#ifndef MODULE
static int i810fb_init(void)
{
- char *option = NULL;
+ const char *option = NULL;
if (fb_modesetting_disabled("i810fb"))
return -ENODEV;
@@ -1620,7 +1620,7 @@ imsttfb_setup(const char *options)
static int __init imsttfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("imsttfb"))
@@ -846,7 +846,7 @@ static struct lcd_ops imxfb_lcd_ops = {
static int imxfb_setup(void)
{
- char *options = NULL;
+ const char *options = NULL;
struct option_iter iter;
const char *opt;
@@ -390,7 +390,7 @@ static int __init intelfb_setup(const char *options)
static int __init intelfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
DBG_MSG("intelfb_init\n");
@@ -797,7 +797,7 @@ static void kyrofb_remove(struct pci_dev *pdev)
static int __init kyrofb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("kyrofb"))
@@ -541,7 +541,7 @@ static int __init macfb_init(void)
{
int video_cmap_len, video_is_nubus = 0;
struct nubus_rsrc *ndev = NULL;
- char *option = NULL;
+ const char *option = NULL;
int err;
if (fb_get_options("macfb", &option))
@@ -2475,7 +2475,7 @@ static int __initdata initialized = 0;
static int __init matroxfb_init(void)
{
- char *option = NULL;
+ const char *option = NULL;
int err = 0;
DBG(__func__)
@@ -1654,7 +1654,7 @@ static struct platform_driver mx3fb_driver = {
static int __init mx3fb_setup(void)
{
#ifndef MODULE
- char *options = NULL;
+ const char *options = NULL;
struct option_iter iter;
const char *opt;
@@ -2218,7 +2218,7 @@ static int __init neofb_setup(const char *options)
static int __init neofb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("neofb"))
@@ -1537,7 +1537,7 @@ static struct pci_driver nvidiafb_driver = {
static int nvidiafb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("nvidiafb"))
@@ -417,7 +417,7 @@ static struct platform_driver ocfb_driver = {
static int __init ocfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("ocfb", &option))
return -ENODEV;
@@ -1905,7 +1905,7 @@ static int __init omapfb_setup(const char *options)
static int __init omapfb_init(void)
{
#ifndef MODULE
- char *option;
+ const char *option;
if (fb_get_options("omapfb", &option))
return -ENODEV;
@@ -683,7 +683,7 @@ static struct platform_driver platinum_driver =
static int __init platinumfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("platinumfb", &option))
return -ENODEV;
@@ -1814,7 +1814,7 @@ static int __init pm2fb_setup(const char *options)
static int __init pm2fb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("pm2fb"))
@@ -1550,7 +1550,7 @@ static int __init pm3fb_init(void)
* For kernel boot options (in 'video=pm3fb:<options>' format)
*/
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("pm3fb"))
@@ -1256,7 +1256,7 @@ static struct ps3_system_bus_driver ps3fb_driver = {
static int __init ps3fb_setup(void)
{
- char *options;
+ const char *options;
struct option_iter iter;
const char *this_opt;
@@ -1090,7 +1090,7 @@ static int __init pvr2fb_init(void)
int i, ret = -ENODEV;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("pvr2fb"))
@@ -2040,7 +2040,7 @@ static char g_options[256] = "";
#ifndef MODULE
static int __init pxafb_setup_options(void)
{
- char *options = NULL;
+ const char *options = NULL;
if (fb_get_options("pxafb", &options))
return -ENODEV;
@@ -2172,7 +2172,7 @@ static struct pci_driver rivafb_driver = {
static int rivafb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("rivafb"))
@@ -1566,7 +1566,7 @@ static int __init s3fb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("s3fb"))
@@ -2564,7 +2564,7 @@ static int __init savagefb_setup(const char *options)
static int __init savagefb_init(void)
{
- char *option;
+ const char *option;
DBG("savagefb_init");
@@ -6587,7 +6587,7 @@ static struct pci_driver sisfb_driver = {
static int __init sisfb_init(void)
{
#ifndef MODULE
- char *options = NULL;
+ const char *options = NULL;
#endif
if (fb_modesetting_disabled("sisfb"))
@@ -899,7 +899,7 @@ static int __init xxxfb_init(void)
* For kernel boot options (in 'video=xxxfb:<options>' format)
*/
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("xxxfb", &option))
return -ENODEV;
@@ -1754,7 +1754,7 @@ static struct pci_driver smtcfb_driver = {
static int __init sm712fb_init(void)
{
- char *option = NULL;
+ const char *option = NULL;
if (fb_modesetting_disabled("sm712fb"))
return -ENODEV;
@@ -1512,7 +1512,7 @@ static struct pci_driver sstfb_driver = {
static int sstfb_init(void)
{
- char *option = NULL;
+ const char *option = NULL;
if (fb_modesetting_disabled("sstfb"))
return -ENODEV;
@@ -1401,7 +1401,7 @@ static int __init stifb_init(void)
int i;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("stifb", &option))
return -ENODEV;
@@ -1640,7 +1640,7 @@ static void tdfxfb_remove(struct pci_dev *pdev)
static int __init tdfxfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("tdfxfb"))
@@ -1605,7 +1605,7 @@ static int tgafb_init(void)
{
int status;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("tgafb"))
@@ -1823,7 +1823,7 @@ static int __init tridentfb_setup(const char *options)
static int __init tridentfb_init(void)
{
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("tridentfb"))
@@ -1891,7 +1891,7 @@ static int uvesafb_init(void)
int err;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("uvesafb", &option))
return -ENODEV;
@@ -304,7 +304,7 @@ static int __init valkyriefb_init(void)
struct fb_info_valkyrie *p;
unsigned long frame_buffer_phys, cmap_regs_phys;
int err;
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("valkyriefb", &option))
return -ENODEV;
@@ -253,7 +253,7 @@ static int vesafb_probe(struct platform_device *dev)
unsigned int size_vmode;
unsigned int size_remap;
unsigned int size_total;
- char *option = NULL;
+ const char *option = NULL;
/* ignore error return of fb_get_options */
fb_get_options("vesafb", &option);
@@ -518,7 +518,7 @@ static int __init vfb_init(void)
int ret = 0;
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
if (fb_get_options("vfb", &option))
return -ENODEV;
@@ -1923,7 +1923,7 @@ void via_fb_pci_remove(struct pci_dev *pdev)
#ifndef MODULE
static int __init viafb_setup(void)
{
- char *options;
+ const char *options;
struct option_iter iter;
const char *this_opt;
@@ -917,9 +917,8 @@ static void __exit vt8623fb_cleanup(void)
static int __init vt8623fb_init(void)
{
-
#ifndef MODULE
- char *option = NULL;
+ const char *option = NULL;
#endif
if (fb_modesetting_disabled("vt8623fb"))
@@ -601,7 +601,7 @@ extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u3
extern void fb_set_suspend(struct fb_info *info, int state);
extern int fb_get_color_depth(struct fb_var_screeninfo *var,
struct fb_fix_screeninfo *fix);
-extern int fb_get_options(const char *name, char **option);
+extern int fb_get_options(const char *name, const char **option);
extern int fb_new_modelist(struct fb_info *info);
extern bool fb_center_logo;
Return the option string as const char* from fb_get_options() to enforce fbdev's ownership of the memory region. Also avoids memory allocation within fb_get_options(). Callers that have to modify the option string must create their own copy. As most drivers use struct option_iter, this already happens transparently in many cases. Adapt all callers of fb_get_options(). Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> --- drivers/staging/sm750fb/sm750.c | 2 +- drivers/video/fbdev/acornfb.c | 2 +- drivers/video/fbdev/amifb.c | 2 +- drivers/video/fbdev/arkfb.c | 2 +- drivers/video/fbdev/atafb.c | 2 +- drivers/video/fbdev/aty/aty128fb.c | 2 +- drivers/video/fbdev/aty/atyfb_base.c | 2 +- drivers/video/fbdev/aty/radeon_base.c | 2 +- drivers/video/fbdev/au1100fb.c | 2 +- drivers/video/fbdev/au1200fb.c | 2 +- drivers/video/fbdev/cirrusfb.c | 2 +- drivers/video/fbdev/controlfb.c | 2 +- drivers/video/fbdev/core/fb_cmdline.c | 13 +++---------- drivers/video/fbdev/core/modedb.c | 8 ++------ drivers/video/fbdev/cyber2000fb.c | 2 +- drivers/video/fbdev/efifb.c | 2 +- drivers/video/fbdev/ep93xx-fb.c | 2 +- drivers/video/fbdev/fm2fb.c | 2 +- drivers/video/fbdev/fsl-diu-fb.c | 2 +- drivers/video/fbdev/gbefb.c | 2 +- drivers/video/fbdev/geode/gx1fb_core.c | 2 +- drivers/video/fbdev/geode/gxfb_core.c | 2 +- drivers/video/fbdev/geode/lxfb_core.c | 2 +- drivers/video/fbdev/grvga.c | 3 ++- drivers/video/fbdev/gxt4500.c | 2 +- drivers/video/fbdev/hyperv_fb.c | 2 +- drivers/video/fbdev/i740fb.c | 2 +- drivers/video/fbdev/i810/i810_main.c | 2 +- drivers/video/fbdev/imsttfb.c | 2 +- drivers/video/fbdev/imxfb.c | 2 +- drivers/video/fbdev/intelfb/intelfbdrv.c | 2 +- drivers/video/fbdev/kyro/fbdev.c | 2 +- drivers/video/fbdev/macfb.c | 2 +- drivers/video/fbdev/matrox/matroxfb_base.c | 2 +- drivers/video/fbdev/mx3fb.c | 2 +- drivers/video/fbdev/neofb.c | 2 +- drivers/video/fbdev/nvidia/nvidia.c | 2 +- drivers/video/fbdev/ocfb.c | 2 +- drivers/video/fbdev/omap/omapfb_main.c | 2 +- drivers/video/fbdev/platinumfb.c | 2 +- drivers/video/fbdev/pm2fb.c | 2 +- drivers/video/fbdev/pm3fb.c | 2 +- drivers/video/fbdev/ps3fb.c | 2 +- drivers/video/fbdev/pvr2fb.c | 2 +- drivers/video/fbdev/pxafb.c | 2 +- drivers/video/fbdev/riva/fbdev.c | 2 +- drivers/video/fbdev/s3fb.c | 2 +- drivers/video/fbdev/savage/savagefb_driver.c | 2 +- drivers/video/fbdev/sis/sis_main.c | 2 +- drivers/video/fbdev/skeletonfb.c | 2 +- drivers/video/fbdev/sm712fb.c | 2 +- drivers/video/fbdev/sstfb.c | 2 +- drivers/video/fbdev/stifb.c | 2 +- drivers/video/fbdev/tdfxfb.c | 2 +- drivers/video/fbdev/tgafb.c | 2 +- drivers/video/fbdev/tridentfb.c | 2 +- drivers/video/fbdev/uvesafb.c | 2 +- drivers/video/fbdev/valkyriefb.c | 2 +- drivers/video/fbdev/vesafb.c | 2 +- drivers/video/fbdev/vfb.c | 2 +- drivers/video/fbdev/via/viafbdev.c | 2 +- drivers/video/fbdev/vt8623fb.c | 3 +-- include/linux/fb.h | 2 +- 63 files changed, 67 insertions(+), 78 deletions(-)