Skip to content

Commit eacf91b

Browse files
committed
Merge tag 'fbdev-for-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
Pull fbdev updates from Helge Deller: "One potential buffer overflow fix in the framebuffer registration function, some fixes for the imxfb, nvidiafb and simplefb drivers, and a bunch of cleanups for fbcon, kyrofb and svgalib. Framework fixes: - fix potential buffer overflow in do_register_framebuffer() [Yongzhen Zhang] Driver fixes: - imxfb: prevent null-ptr-deref [Chenyuan Yang] - nvidiafb: fix build on 32-bit ARCH=um [Johannes Berg] - nvidiafb: add depends on HAS_IOPORT [Randy Dunlap] - simplefb: Use of_reserved_mem_region_to_resource() for "memory-region" [Rob Herring] Cleanups: - fbcon: various code cleanups wrt blinking [Ville Syrjälä] - kyrofb: Convert to devm_*() functions [Giovanni Di Santi] - svgalib: Coding style cleanups [Darshan R.] - Fix typo in Kconfig text for FB_DEVICE [Daniel Palmer]" * tag 'fbdev-for-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev: fbcon: Use 'bool' where appopriate fbcon: Introduce get_{fg,bg}_color() fbcon: fbcon_is_inactive() -> fbcon_is_active() fbcon: fbcon_cursor_noblink -> fbcon_cursor_blink fbdev: Fix typo in Kconfig text for FB_DEVICE fbdev: imxfb: Check fb_add_videomode to prevent null-ptr-deref fbdev: svgalib: Clean up coding style fbdev: kyro: Use devm_ioremap_wc() for screen mem fbdev: kyro: Use devm_ioremap() for mmio registers fbdev: kyro: Add missing PCI memory region request fbdev: simplefb: Use of_reserved_mem_region_to_resource() for "memory-region" fbdev: fix potential buffer overflow in do_register_framebuffer() fbdev: nvidiafb: add depends on HAS_IOPORT fbdev: nvidiafb: fix build on 32-bit ARCH=um
2 parents 7061835 + 81b96e4 commit eacf91b

File tree

9 files changed

+116
-115
lines changed

9 files changed

+116
-115
lines changed

drivers/video/fbdev/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ config FB_ATMEL
660660

661661
config FB_NVIDIA
662662
tristate "nVidia Framebuffer Support"
663-
depends on FB && PCI
663+
depends on FB && PCI && HAS_IOPORT
664664
select FB_CFB_FILLRECT
665665
select FB_CFB_COPYAREA
666666
select FB_CFB_IMAGEBLIT

drivers/video/fbdev/core/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ config FB_DEVICE
1616
default FB
1717
help
1818
Say Y here if you want the legacy /dev/fb* device file and
19-
interfaces within sysfs anc procfs. It is only required if you
19+
interfaces within sysfs and procfs. It is only required if you
2020
have userspace programs that depend on fbdev for graphics output.
2121
This does not affect the framebuffer console. If unsure, say N.
2222

drivers/video/fbdev/core/fbcon.c

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ static int logo_shown = FBCON_LOGO_CANSHOW;
135135
/* console mappings */
136136
static unsigned int first_fb_vc;
137137
static unsigned int last_fb_vc = MAX_NR_CONSOLES - 1;
138-
static int fbcon_is_default = 1;
138+
static bool fbcon_is_default = true;
139139
static int primary_device = -1;
140-
static int fbcon_has_console_bind;
140+
static bool fbcon_has_console_bind;
141141

142142
#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
143143
static int map_override;
@@ -172,7 +172,7 @@ static const struct consw fb_con;
172172

173173
#define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row)
174174

175-
static int fbcon_cursor_noblink;
175+
static bool fbcon_cursor_blink = true;
176176

177177
#define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)
178178

@@ -289,16 +289,16 @@ static bool fbcon_skip_panic(struct fb_info *info)
289289
#endif
290290
}
291291

292-
static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
292+
static inline bool fbcon_is_active(struct vc_data *vc, struct fb_info *info)
293293
{
294294
struct fbcon_ops *ops = info->fbcon_par;
295295

296-
return (info->state != FBINFO_STATE_RUNNING ||
297-
vc->vc_mode != KD_TEXT || ops->graphics || fbcon_skip_panic(info));
296+
return info->state == FBINFO_STATE_RUNNING &&
297+
vc->vc_mode == KD_TEXT && !ops->graphics && !fbcon_skip_panic(info);
298298
}
299299

300300
static int get_color(struct vc_data *vc, struct fb_info *info,
301-
u16 c, int is_fg)
301+
u16 c, bool is_fg)
302302
{
303303
int depth = fb_get_color_depth(&info->var, &info->fix);
304304
int color = 0;
@@ -364,6 +364,16 @@ static int get_color(struct vc_data *vc, struct fb_info *info,
364364
return color;
365365
}
366366

367+
static int get_fg_color(struct vc_data *vc, struct fb_info *info, u16 c)
368+
{
369+
return get_color(vc, info, c, true);
370+
}
371+
372+
static int get_bg_color(struct vc_data *vc, struct fb_info *info, u16 c)
373+
{
374+
return get_color(vc, info, c, false);
375+
}
376+
367377
static void fb_flashcursor(struct work_struct *work)
368378
{
369379
struct fbcon_ops *ops = container_of(work, struct fbcon_ops, cursor_work.work);
@@ -395,8 +405,9 @@ static void fb_flashcursor(struct work_struct *work)
395405

396406
c = scr_readw((u16 *) vc->vc_pos);
397407
enable = ops->cursor_flash && !ops->cursor_state.enable;
398-
ops->cursor(vc, info, enable, get_color(vc, info, c, 1),
399-
get_color(vc, info, c, 0));
408+
ops->cursor(vc, info, enable,
409+
get_fg_color(vc, info, c),
410+
get_bg_color(vc, info, c));
400411
console_unlock();
401412

402413
queue_delayed_work(system_power_efficient_wq, &ops->cursor_work,
@@ -407,7 +418,7 @@ static void fbcon_add_cursor_work(struct fb_info *info)
407418
{
408419
struct fbcon_ops *ops = info->fbcon_par;
409420

410-
if (!fbcon_cursor_noblink)
421+
if (fbcon_cursor_blink)
411422
queue_delayed_work(system_power_efficient_wq, &ops->cursor_work,
412423
ops->cur_blink_jiffies);
413424
}
@@ -464,7 +475,7 @@ static int __init fb_console_setup(char *this_opt)
464475
last_fb_vc = simple_strtoul(options, &options, 10) - 1;
465476
if (last_fb_vc < first_fb_vc || last_fb_vc >= MAX_NR_CONSOLES)
466477
last_fb_vc = MAX_NR_CONSOLES - 1;
467-
fbcon_is_default = 0;
478+
fbcon_is_default = false;
468479
continue;
469480
}
470481

@@ -559,7 +570,7 @@ static int do_fbcon_takeover(int show_logo)
559570
con2fb_map[i] = -1;
560571
info_idx = -1;
561572
} else {
562-
fbcon_has_console_bind = 1;
573+
fbcon_has_console_bind = true;
563574
}
564575

565576
return err;
@@ -1267,7 +1278,7 @@ static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
12671278
struct fbcon_display *p = &fb_display[vc->vc_num];
12681279
u_int y_break;
12691280

1270-
if (fbcon_is_inactive(vc, info))
1281+
if (!fbcon_is_active(vc, info))
12711282
return;
12721283

12731284
if (!height || !width)
@@ -1311,18 +1322,18 @@ static void fbcon_putcs(struct vc_data *vc, const u16 *s, unsigned int count,
13111322
struct fbcon_display *p = &fb_display[vc->vc_num];
13121323
struct fbcon_ops *ops = info->fbcon_par;
13131324

1314-
if (!fbcon_is_inactive(vc, info))
1325+
if (fbcon_is_active(vc, info))
13151326
ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1316-
get_color(vc, info, scr_readw(s), 1),
1317-
get_color(vc, info, scr_readw(s), 0));
1327+
get_fg_color(vc, info, scr_readw(s)),
1328+
get_bg_color(vc, info, scr_readw(s)));
13181329
}
13191330

13201331
static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
13211332
{
13221333
struct fb_info *info = fbcon_info_from_console(vc->vc_num);
13231334
struct fbcon_ops *ops = info->fbcon_par;
13241335

1325-
if (!fbcon_is_inactive(vc, info))
1336+
if (fbcon_is_active(vc, info))
13261337
ops->clear_margins(vc, info, margin_color, bottom_only);
13271338
}
13281339

@@ -1334,7 +1345,7 @@ static void fbcon_cursor(struct vc_data *vc, bool enable)
13341345

13351346
ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms);
13361347

1337-
if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1)
1348+
if (!fbcon_is_active(vc, info) || vc->vc_deccm != 1)
13381349
return;
13391350

13401351
if (vc->vc_cursor_type & CUR_SW)
@@ -1347,8 +1358,9 @@ static void fbcon_cursor(struct vc_data *vc, bool enable)
13471358
if (!ops->cursor)
13481359
return;
13491360

1350-
ops->cursor(vc, info, enable, get_color(vc, info, c, 1),
1351-
get_color(vc, info, c, 0));
1361+
ops->cursor(vc, info, enable,
1362+
get_fg_color(vc, info, c),
1363+
get_bg_color(vc, info, c));
13521364
}
13531365

13541366
static int scrollback_phys_max = 0;
@@ -1740,7 +1752,7 @@ static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
17401752
struct fb_info *info = fbcon_info_from_console(vc->vc_num);
17411753
struct fbcon_display *p = &fb_display[vc->vc_num];
17421754

1743-
if (fbcon_is_inactive(vc, info))
1755+
if (!fbcon_is_active(vc, info))
17441756
return;
17451757

17461758
if (!width || !height)
@@ -1764,7 +1776,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
17641776
struct fbcon_display *p = &fb_display[vc->vc_num];
17651777
int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
17661778

1767-
if (fbcon_is_inactive(vc, info))
1779+
if (!fbcon_is_active(vc, info))
17681780
return true;
17691781

17701782
fbcon_cursor(vc, false);
@@ -2148,7 +2160,7 @@ static bool fbcon_switch(struct vc_data *vc)
21482160
fbcon_del_cursor_work(old_info);
21492161
}
21502162

2151-
if (fbcon_is_inactive(vc, info) ||
2163+
if (!fbcon_is_active(vc, info) ||
21522164
ops->blank_state != FB_BLANK_UNBLANK)
21532165
fbcon_del_cursor_work(info);
21542166
else
@@ -2188,7 +2200,7 @@ static bool fbcon_switch(struct vc_data *vc)
21882200
scrollback_max = 0;
21892201
scrollback_current = 0;
21902202

2191-
if (!fbcon_is_inactive(vc, info)) {
2203+
if (fbcon_is_active(vc, info)) {
21922204
ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
21932205
ops->update_start(info);
21942206
}
@@ -2244,7 +2256,7 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
22442256
}
22452257
}
22462258

2247-
if (!fbcon_is_inactive(vc, info)) {
2259+
if (fbcon_is_active(vc, info)) {
22482260
if (ops->blank_state != blank) {
22492261
ops->blank_state = blank;
22502262
fbcon_cursor(vc, !blank);
@@ -2258,7 +2270,7 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
22582270
update_screen(vc);
22592271
}
22602272

2261-
if (mode_switch || fbcon_is_inactive(vc, info) ||
2273+
if (mode_switch || !fbcon_is_active(vc, info) ||
22622274
ops->blank_state != FB_BLANK_UNBLANK)
22632275
fbcon_del_cursor_work(info);
22642276
else
@@ -2588,7 +2600,7 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)
25882600
int i, j, k, depth;
25892601
u8 val;
25902602

2591-
if (fbcon_is_inactive(vc, info))
2603+
if (!fbcon_is_active(vc, info))
25922604
return;
25932605

25942606
if (!con_is_visible(vc))
@@ -2688,7 +2700,7 @@ static void fbcon_modechanged(struct fb_info *info)
26882700
scrollback_max = 0;
26892701
scrollback_current = 0;
26902702

2691-
if (!fbcon_is_inactive(vc, info)) {
2703+
if (fbcon_is_active(vc, info)) {
26922704
ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
26932705
ops->update_start(info);
26942706
}
@@ -2806,7 +2818,7 @@ static void fbcon_unbind(void)
28062818
fbcon_is_default);
28072819

28082820
if (!ret)
2809-
fbcon_has_console_bind = 0;
2821+
fbcon_has_console_bind = false;
28102822
}
28112823
#else
28122824
static inline void fbcon_unbind(void) {}
@@ -3257,8 +3269,9 @@ static ssize_t cursor_blink_store(struct device *device,
32573269
const char *buf, size_t count)
32583270
{
32593271
struct fb_info *info;
3260-
int blink, idx;
32613272
char **last = NULL;
3273+
bool blink;
3274+
int idx;
32623275

32633276
console_lock();
32643277
idx = con2fb_map[fg_console];
@@ -3274,10 +3287,10 @@ static ssize_t cursor_blink_store(struct device *device,
32743287
blink = simple_strtoul(buf, last, 0);
32753288

32763289
if (blink) {
3277-
fbcon_cursor_noblink = 0;
3290+
fbcon_cursor_blink = true;
32783291
fbcon_add_cursor_work(info);
32793292
} else {
3280-
fbcon_cursor_noblink = 1;
3293+
fbcon_cursor_blink = false;
32813294
fbcon_del_cursor_work(info);
32823295
}
32833296

drivers/video/fbdev/core/fbmem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ static int do_register_framebuffer(struct fb_info *fb_info)
449449
if (!registered_fb[i])
450450
break;
451451

452+
if (i >= FB_MAX)
453+
return -ENXIO;
454+
452455
if (!fb_info->modelist.prev || !fb_info->modelist.next)
453456
INIT_LIST_HEAD(&fb_info->modelist);
454457

0 commit comments

Comments
 (0)