1. 10 8月, 2015 1 次提交
  2. 27 5月, 2015 1 次提交
    • T
      fbcon: Avoid deleting a timer in IRQ context · a5edce42
      Thierry Reding 提交于
      Commit 27a4c827 ("fbcon: use the cursor blink interval provided by
      vt") unconditionally removes the cursor blink timer. Unfortunately that
      wreaks havoc under some circumstances. An easily reproducible way is to
      use both the framebuffer console and a debug serial port as the console
      output for kernel messages (e.g. "console=ttyS0 console=tty1" on the
      kernel command-line. Upon boot this triggers a warning from within the
      del_timer_sync() function because it is called from IRQ context:
      
      	[    5.070096] ------------[ cut here ]------------
      	[    5.070110] WARNING: CPU: 0 PID: 0 at ../kernel/time/timer.c:1098 del_timer_sync+0x4c/0x54()
      	[    5.070115] Modules linked in:
      	[    5.070120] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.0-rc4-next-20150519 #1
      	[    5.070123] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
      	[    5.070142] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
      	[    5.070156] [] (show_stack) from [] (dump_stack+0x70/0xbc)
      	[    5.070164] [] (dump_stack) from [] (warn_slowpath_common+0x74/0xb0)
      	[    5.070169] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24)
      	[    5.070174] [] (warn_slowpath_null) from [] (del_timer_sync+0x4c/0x54)
      	[    5.070183] [] (del_timer_sync) from [] (fbcon_del_cursor_timer+0x2c/0x40)
      	[    5.070190] [] (fbcon_del_cursor_timer) from [] (fbcon_cursor+0x9c/0x180)
      	[    5.070198] [] (fbcon_cursor) from [] (hide_cursor+0x30/0x98)
      	[    5.070204] [] (hide_cursor) from [] (vt_console_print+0x2a8/0x340)
      	[    5.070212] [] (vt_console_print) from [] (call_console_drivers.constprop.23+0xc8/0xec)
      	[    5.070218] [] (call_console_drivers.constprop.23) from [] (console_unlock+0x498/0x4f0)
      	[    5.070223] [] (console_unlock) from [] (vprintk_emit+0x1f0/0x508)
      	[    5.070228] [] (vprintk_emit) from [] (vprintk_default+0x24/0x2c)
      	[    5.070234] [] (vprintk_default) from [] (printk+0x70/0x88)
      
      After which the system starts spewing all kinds of weird and seemingly
      unrelated error messages.
      
      This commit fixes this by restoring the condition under which the call
      to fbcon_del_cursor_timer() happens.
      Reported-by: NDaniel Stone <daniel@fooishbar.org>
      Reported-by: NKevin Hilman <khilman@kernel.org>
      Tested-by: NKevin Hilman <khilman@linaro.org>
      Tested-by: NScot Doyle <lkml14@scotdoyle.com>
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Tested-by: NAndrew Vagin <avagin@virtuozzo.com>
      Tested-by: NTomeu Vizoso <tomeu.vizoso@collabora.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5edce42
  3. 11 5月, 2015 1 次提交
  4. 26 1月, 2015 1 次提交
  5. 14 11月, 2014 1 次提交
  6. 22 10月, 2014 1 次提交
  7. 09 5月, 2014 1 次提交
    • M
      fbcon: Fix memory leak in con2fb_release_oldinfo() · 7a966fbd
      Masami Ichikawa 提交于
      kmemleak reported a memory leak as below.
      
      unreferenced object 0xffff8800dab6d8d8 (size 96):
        comm "swapper/0", pid 1, jiffies 4294877598 (age 38.483s)
        hex dump (first 32 bytes):
          00 00 00 00 00 01 00 00 08 00 00 00 10 00 00 00  ................
          07 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff814e8f2e>] kmemleak_alloc+0x4e/0xb0
          [<ffffffff811a0600>] __kmalloc+0x280/0x320
          [<ffffffff81309b61>] soft_cursor+0x231/0x290
          [<ffffffff81309393>] bit_cursor+0x613/0x650
          [<ffffffff8130556b>] fbcon_cursor+0x13b/0x1c0
          [<ffffffff813755f8>] hide_cursor+0x28/0xa0
          [<ffffffff81376e98>] redraw_screen+0x168/0x240
          [<ffffffff81303891>] fbcon_prepare_logo+0x381/0x420
          [<ffffffff81303c7e>] fbcon_init+0x34e/0x590
          [<ffffffff81375828>] visual_init+0xb8/0x120
          [<ffffffff81377c93>] do_bind_con_driver+0x163/0x380
          [<ffffffff81378494>] do_take_over_console+0x114/0x1c0
          [<ffffffff81303f23>] do_fbcon_takeover+0x63/0xd0
          [<ffffffff813086dd>] fbcon_event_notify+0x68d/0x7e0
          [<ffffffff814ff7ac>] notifier_call_chain+0x4c/0x70
          [<ffffffff8108c85d>] __blocking_notifier_call_chain+0x4d/0x70
      
      This memory leak cause is, fbcon_ops's cursor_src is allocated in
      soft_cursor() but not released in con2fb_release_oldinfo().
      so, cursor_src is needed to be released when oldinfo is going to be
      released.
      Signed-off-by: NMasami Ichikawa <masami256@gmail.com>
      Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      7a966fbd
  8. 11 2月, 2014 1 次提交
    • K
      fbcon: Clean up fbcon data in fb_info on FB_EVENT_FB_UNBIND with 0 fbs · 5f4dc28b
      Keith Packard 提交于
      When FB_EVENT_FB_UNBIND is sent, fbcon has two paths, one path taken
      when there is another frame buffer to switch any affected vcs to and
      another path when there isn't.
      
      In the case where there is another frame buffer to use,
      fbcon_fb_unbind calls set_con2fb_map to remap all of the affected vcs
      to the replacement frame buffer. set_con2fb_map will eventually call
      con2fb_release_oldinfo when the last vcs gets unmapped from the old
      frame buffer.
      
      con2fb_release_oldinfo frees the fbcon data that is hooked off of the
      fb_info structure, including the cursor timer.
      
      In the case where there isn't another frame buffer to use,
      fbcon_fb_unbind simply calls fbcon_unbind, which doesn't clear the
      con2fb_map or free the fbcon data hooked from the fb_info
      structure. In particular, it doesn't stop the cursor blink timer. When
      the fb_info structure is then freed, we end up with a timer queue
      pointing into freed memory and "bad things" start happening.
      
      This patch first changes con2fb_release_oldinfo so that it can take a
      NULL pointer for the new frame buffer, but still does all of the
      deallocation and cursor timer cleanup.
      
      Finally, the patch tries to replicate some of what set_con2fb_map does
      by clearing the con2fb_map for the affected vcs and calling the
      modified con2fb_release_info function to clean up the fb_info structure.
      Signed-off-by: NKeith Packard <keithp@keithp.com>
      Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      5f4dc28b
  9. 17 1月, 2014 2 次提交
    • M
      fbcon: Fix memory leak in fbcon_exit(). · 46862145
      Masami Ichikawa 提交于
      kmemleak reported a memory leak as below.
      
      unreferenced object 0xffff880036ca84c0 (size 16):
        comm "swapper/0", pid 1, jiffies 4294877407 (age 4434.633s)
        hex dump (first 16 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff  ................
        backtrace:
          [<ffffffff814ed01e>] kmemleak_alloc+0x4e/0xb0
          [<ffffffff8118913c>] __kmalloc+0x1fc/0x290
          [<ffffffff81302c9e>] bit_cursor+0x24e/0x6c0
          [<ffffffff812ff2f4>] fbcon_cursor+0x154/0x1d0
          [<ffffffff813675d8>] hide_cursor+0x28/0xa0
          [<ffffffff81368acf>] update_region+0x6f/0x90
          [<ffffffff81300268>] fbcon_switch+0x518/0x550
          [<ffffffff813695b9>] redraw_screen+0x189/0x240
          [<ffffffff8136a0e0>] do_bind_con_driver+0x360/0x380
          [<ffffffff8136a6e4>] do_take_over_console+0x114/0x1c0
          [<ffffffff812fdc83>] do_fbcon_takeover+0x63/0xd0
          [<ffffffff813023e5>] fbcon_event_notify+0x605/0x720
          [<ffffffff81501dcc>] notifier_call_chain+0x4c/0x70
          [<ffffffff81087f8d>] __blocking_notifier_call_chain+0x4d/0x70
          [<ffffffff81087fc6>] blocking_notifier_call_chain+0x16/0x20
          [<ffffffff812f201b>] fb_notifier_call_chain+0x1b/0x20
      
      In this case ops->cursor_state.mask is allocated in bit_cursor() but
      not freed in fbcon_exit(). So, fbcon_exit() needs to free buffer in its
      process.
      In the case, fbcon_exit() was called from fbcon_deinit() when driver
      called remove_conflicting_framebuffers().
      Signed-off-by: NMasami Ichikawa <masami256@gmail.com>
      Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      46862145
    • W
      fbcon: trivial optimization for fbcon_exit · 5aa133d6
      Wang YanQing 提交于
      Break out as soon as we find a mapped entry con2fb_map.
      Signed-off-by: NWang YanQing <udknight@gmail.com>
      Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      5aa133d6
  10. 21 5月, 2013 4 次提交
  11. 15 5月, 2013 1 次提交
    • V
      fbcon: queue work on power efficient wq · a85f1a41
      Viresh Kumar 提交于
      fbcon uses workqueues and it has no real dependency of scheduling these on the
      cpu which scheduled them.
      
      On a idle system, it is observed that and idle cpu wakes up many times just to
      service this work. It would be better if we can schedule it on a cpu which the
      scheduler believes to be the most appropriate one.
      
      This patch replaces system_wq with system_power_efficient_wq.
      
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: linux-fbdev@vger.kernel.org
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      a85f1a41
  12. 24 4月, 2013 1 次提交
  13. 22 2月, 2013 1 次提交
  14. 08 2月, 2013 3 次提交
  15. 07 2月, 2013 1 次提交
    • D
      fbcon: don't lose the console font across generic->chip driver switch · ae128786
      Dave Airlie 提交于
      If grub2 loads efifb/vesafb, then when systemd starts it can set the console
      font on that framebuffer device, however when we then load the native KMS
      driver, the first thing it does is tear down the generic framebuffer driver.
      
      The thing is the generic code is doing the right thing, it frees the font
      because otherwise it would leak memory. However we can assume that if you
      are removing the generic firmware driver (vesa/efi/offb), that a new driver
      *should* be loading soon after, so we effectively leak the font.
      
      However the old code left a dangling pointer in vc->vc_font.data and we
      can now reuse that dangling pointer to load the font into the new
      driver, now that we aren't freeing it.
      
      Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=892340
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      ae128786
  16. 23 8月, 2012 1 次提交
  17. 22 8月, 2012 2 次提交
    • D
      fbcon: fix race condition between console lock and cursor timer (v1.1) · d8636a27
      Dave Airlie 提交于
      So we've had a fair few reports of fbcon handover breakage between
      efi/vesafb and i915 surface recently, so I dedicated a couple of
      days to finding the problem.
      
      Essentially the last thing we saw was the conflicting framebuffer
      message and that was all.
      
      So after much tracing with direct netconsole writes (printks
      under console_lock not so useful), I think I found the race.
      
      Thread A (driver load)    Thread B (timer thread)
        unbind_con_driver ->              |
        bind_con_driver ->                |
        vc->vc_sw->con_deinit ->          |
        fbcon_deinit ->                   |
        console_lock()                    |
            |                             |
            |                       fbcon_flashcursor timer fires
            |                       console_lock() <- blocked for A
            |
            |
      fbcon_del_cursor_timer ->
        del_timer_sync
        (BOOM)
      
      Of course because all of this is under the console lock,
      we never see anything, also since we also just unbound the active
      console guess what we never see anything.
      
      Hopefully this fixes the problem for anyone seeing vesafb->kms
      driver handoff.
      
      v1.1: add comment suggestion from Alan.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      d8636a27
    • D
      fbcon: fix race condition between console lock and cursor timer · ec5da7f8
      Dave Airlie 提交于
      So we've had a fair few reports of fbcon handover breakage between
      efi/vesafb and i915 surface recently, so I dedicated a couple of
      days to finding the problem.
      
      Essentially the last thing we saw was the conflicting framebuffer
      message and that was all.
      
      So after much tracing with direct netconsole writes (printks
      under console_lock not so useful), I think I found the race.
      
        Thread A (driver load)    Thread B (timer thread)
          unbind_con_driver ->              |
          bind_con_driver ->                |
          vc->vc_sw->con_deinit ->          |
          fbcon_deinit ->                   |
          console_lock()                    |
              |                             |
              |                       fbcon_flashcursor timer fires
              |                       console_lock() <- blocked for A
              |
              |
        fbcon_del_cursor_timer ->
          del_timer_sync
          (BOOM)
      
      Of course because all of this is under the console lock,
      we never see anything, also since we also just unbound the active
      console guess what we never see anything.
      
      Hopefully this fixes the problem for anyone seeing vesafb->kms
      driver handoff.
      Signed-off-by: NDavid Airlie <airlied@redhat.com>
      Acked-by: NAlan Cox <alan@lxorguk.ukuu.org.uk>
      Cc: stable@vger.kernel.org
      Tested-by: NJosh Boyer <jwboyer@gmail.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ec5da7f8
  18. 29 3月, 2012 1 次提交
  19. 31 3月, 2011 1 次提交
  20. 22 3月, 2011 1 次提交
    • D
      fbcon: fix situation where fbcon gets deinitialised and can't reinit. · 32b98bf8
      Dave Airlie 提交于
      Situation as follow:
      2 GPUs + vesafb + kms.
      
      GPU 1 is primary, vesafb binds to it as fb0
      radeon loads
      GPU 0 loads as fb1
      GPU 1 loads, vesafb gets kicked off which causes fb0 to unbind
      console, which causes the dummy console to rebind.
      
      this means fbcon_deinit gets called, which calls fbcon_exit
      since the console isn't bound anymore and we set fbcon_has_exited.
      
      GPU 1 creates a new fb0 which is primary and we want to be console.
      fbcon_fb_registered gets called sets the primary up and calls set_con2fb_map,
      however as fbcon_has_exited is set nothing further ever happens.
      
      This patch bypasses the fbcon_has_exited and checks if the console is unbound,
      if its unbound it calls the fbcon_takeover which calls the vt layer to
      call the fbcon_startup method and everthing works.
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      Signed-off-by: NPaul Mundt <lethal@linux-sh.org>
      32b98bf8
  21. 26 1月, 2011 1 次提交
    • T
      console: rename acquire/release_console_sem() to console_lock/unlock() · ac751efa
      Torben Hohn 提交于
      The -rt patches change the console_semaphore to console_mutex.  As a
      result, a quite large chunk of the patches changes all
      acquire/release_console_sem() to acquire/release_console_mutex()
      
      This commit makes things use more neutral function names which dont make
      implications about the underlying lock.
      
      The only real change is the return value of console_trylock which is
      inverted from try_acquire_console_sem()
      
      This patch also paves the way to switching console_sem from a semaphore to
      a mutex.
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: make console_trylock return 1 on success, per Geert]
      Signed-off-by: NTorben Hohn <torbenh@gmx.de>
      Cc: Thomas Gleixner <tglx@tglx.de>
      Cc: Greg KH <gregkh@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac751efa
  22. 23 9月, 2010 1 次提交
    • J
      fbcon: fix lockdep warning from fbcon_deinit() · 142092e5
      Jarek Poplawski 提交于
      Fix the lockdep warning:
      
      [   13.657164] INFO: trying to register non-static key.
      [   13.657169] the code is fine but needs lockdep annotation.
      [   13.657171] turning off the locking correctness validator.
      [   13.657177] Pid: 622, comm: modprobe Not tainted 2.6.36-rc3c #8
      [   13.657180] Call Trace:
      [   13.657194]  [<c13002c8>] ? printk+0x18/0x20
      [   13.657202]  [<c1056cf6>] register_lock_class+0x336/0x350
      [   13.657208]  [<c1058bf9>] __lock_acquire+0x449/0x1180
      [   13.657215]  [<c1059997>] lock_acquire+0x67/0x80
      [   13.657222]  [<c1042bf1>] ? __cancel_work_timer+0x51/0x230
      [   13.657227]  [<c1042c23>] __cancel_work_timer+0x83/0x230
      [   13.657231]  [<c1042bf1>] ? __cancel_work_timer+0x51/0x230
      [   13.657236]  [<c10582b2>] ? mark_held_locks+0x62/0x80
      [   13.657243]  [<c10b3a2f>] ? kfree+0x7f/0xe0
      [   13.657248]  [<c105853c>] ? trace_hardirqs_on_caller+0x11c/0x160
      [   13.657253]  [<c105858b>] ? trace_hardirqs_on+0xb/0x10
      [   13.657259]  [<c117f4cd>] ? fbcon_deinit+0x16d/0x1e0
      [   13.657263]  [<c117f4cd>] ? fbcon_deinit+0x16d/0x1e0
      [   13.657268]  [<c1042dea>] cancel_work_sync+0xa/0x10
      [   13.657272]  [<c117f444>] fbcon_deinit+0xe4/0x1e0
      ...
      
      The warning is caused by trying to cancel an uninitialized work from
      fbcon_exit().  Fix it by adding a check for queue.func, similarly to other
      places in this code.
      Signed-off-by: NJarek Poplawski <jarkao2@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      142092e5
  23. 11 8月, 2010 2 次提交
  24. 05 8月, 2010 1 次提交
  25. 01 3月, 2010 1 次提交
    • D
      vga_switcheroo: initial implementation (v15) · 6a9ee8af
      Dave Airlie 提交于
      Many new laptops now come with 2 gpus, one to be used for low power
      modes and one for gaming/on-ac applications. These GPUs are typically
      wired to the laptop panel and VGA ports via a multiplexer unit which
      is controlled via ACPI methods.
      
      4 combinations of systems typically exist - with 2 ACPI methods.
      Intel/ATI - Lenovo W500/T500 - use ATPX ACPI method
      ATI/ATI - some ASUS - use ATPX ACPI Method
      Intel/Nvidia - - use _DSM ACPI method
      Nvidia/Nvidia -  - use _DSM ACPI method.
      
      TODO:
      This patch adds support for the ATPX method and initial bits
      for the _DSM methods that need to written by someone with
      access to the hardware.
      Add a proper non-debugfs interface - need to get some proper
      testing first.
      
      v2: add power up/down support for both devices
      on W500 puts i915/radeon into D3 and cuts power to radeon.
      
      v3: redo probing methods, no DMI list, drm devices call to
      register with switcheroo, it tries to find an ATPX method on
      any device and once there is two devices + ATPX it inits the
      switcher.
      
      v4: ATPX msg handling using buffers - should work on more machines
      
      v5: rearchitect after more mjg59 discussion - move ATPX handling to
          radeon driver.
      
      v6: add file headers + initial nouveau bits (to be filled out).
      
      v7: merge delayed switcher code.
      
      v8: avoid suspend/resume of gpu that is off
      
      v9: rearchitect - mjg59 is always right. - move all ATPX code to
      radeon, should allow simpler DSM also proper ATRM handling
      
      v10: add ATRM support for radeon BIOS, add mutex to lock vgasr_priv
      
      v11: fix bug in resuming Intel for 2nd time.
      
      v12: start fixing up nvidia code blindly.
      
      v13: blindly guess at finishing nvidia code
      
      v14: remove radeon audio hacks - fix up intel resume more like upstream
      
      v15: clean up printks + remove unnecessary igd/dis pointers
      
      mount debugfs
      
      /sys/kernel/debug/vgaswitcheroo/switch - should exist if ATPX detected
       + 2 cards.
      
      DIS - immediate change to discrete
      IGD - immediate change to IGD
      DDIS - delayed change to discrete
      DIGD - delayed change to IGD
      ON - turn on not in use
      OFF - turn off not in use
      
      Tested on W500 (Intel/ATI) and T500 (Intel/ATI)
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      6a9ee8af
  26. 12 11月, 2009 1 次提交
  27. 23 9月, 2009 2 次提交
    • I
      fbcon: only unbind from console if successfully registered · 2ddce3fd
      Ian Armstrong 提交于
      Attempting to unload a framebuffer module calls unregister_framebuffer()
      which in turn gets fbcon to release it.  If fbcon has no framebuffers
      linked to a console, it will also unbind itself from the console driver.
      However, if fbcon never registered itself as a console driver, the unbind
      will fail causing the framebuffer device entry to persist.  In most cases
      this failure will result in an oops when attempting to access the now
      non-existent device.
      
      This patch ensures that the fbcon unbind request will succeed even if a
      bind was never done.  It tracks if a successful bind ever occurred & will
      only attempt to unbind if needed.  If there never was a bind, it simply
      returns with no error.
      Signed-off-by: NIan Armstrong <ian@iarmst.demon.co.uk>
      Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2ddce3fd
    • F
      fb: do not ignore fb_set_par errors · 0fcf6ada
      Florian Tobias Schandinat 提交于
      At the moment about half of the framebuffer drivers can return an error
      code in fb_set_par. Until now it would be silently ignored by fbmem.c
      and fbcon.c. This patch fixes fbmem.c to return the error code and
      restore var on error.
      
      But it is not clear in which video mode the device is when fb_set_par
      fails.  It would be good and reasonable if it were in the old state but
      there is no guarantee that this is true for all existing drivers.
      Additionally print a message if a failing fb_set_par is detected in
      fbmem.c or fbcon.c.
      
      Although most errors should be caught by the previous fb_check_var some
      errors can't as they are dynamic (memory allocations, ...) and can only be
      detected while performing the operations which is forbidden in
      fb_check_var.
      
      This patch shouldn't have a negative impact on normal operation as all
      drivers return 0 on success.  The impact in case of error depends heavily
      on the driver and caller but it's expected to be better than before.
      Signed-off-by: NFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0fcf6ada
  28. 08 8月, 2009 1 次提交
    • J
      fbcon: don't use vc_resize() on initialization · 0035fe00
      Johannes Weiner 提交于
      Catalin and kmemleak spotted a leak of a VC screen buffer in
      vc_allocate() due to the following chain of events:
      
      	vc_allocate()
      	  visual_init(init=1)
      	    vc->vc_sw->con_init(init=1)
                    fbcon_init()
      	        vc_resize()
      	          vc->screen_buf = kmalloc()
      	  vc->screen_buf = kmalloc()
      
      The common way for the VC drivers is to set the screen dimension
      parameters manually in the init case and only call vc_resize() for
      !init - which allocates a screen buffer according to the new
      dimensions.
      
      fbcon instead would do vc_resize() unconditionally and afterwards set
      the dimensions manually (again) for !init - i.e. completely upside
      down.  The vc_resize() allocated buffer would then get lost by
      vc_allocate() allocating a fresh one.
      
      Use vc_resize() only for actual resizing to close the leak.
      
      Set the dimensions manually only in initialization mode to remove the
      redundant setting in resize mode.
      
      The kmemleak trace from Catalin:
      
      unreferenced object 0xde158000 (size 12288):
        comm "Xorg", pid 1439, jiffies 4294961016
        hex dump (first 32 bytes):
          20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00   . . . . . . . .
          20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00   . . . . . . . .
        backtrace:
          [<c006f74b>] __save_stack_trace+0x17/0x1c
          [<c006f81d>] create_object+0xcd/0x188
          [<c01f5457>] kmemleak_alloc+0x1b/0x3c
          [<c006e303>] __kmalloc+0xdb/0xe8
          [<c012cc4b>] vc_do_resize+0x73/0x1e0
          [<c012cdf1>] vc_resize+0x15/0x18
          [<c011afc1>] fbcon_init+0x1f9/0x2b8
          [<c0129e87>] visual_init+0x9f/0xdc
          [<c012aff3>] vc_allocate+0x7f/0xfc
          [<c012b087>] con_open+0x17/0x80
          [<c0120e43>] tty_open+0x1f7/0x2e4
          [<c0072fa1>] chrdev_open+0x101/0x118
          [<c006ffad>] __dentry_open+0x105/0x1cc
          [<c00700fd>] nameidata_to_filp+0x2d/0x38
          [<c00788cd>] do_filp_open+0x2c1/0x54c
          [<c006fdff>] do_sys_open+0x3b/0xb4
      Reported-by: NCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: NJohannes Weiner <hannes@cmpxchg.org>
      Tested-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Pekka Enberg <penberg@cs.helsinki.fi>
      Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
      Tested-by: NDave Young <hidave.darkstar@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0035fe00
  29. 14 4月, 2009 1 次提交
  30. 01 4月, 2009 1 次提交
  31. 13 1月, 2009 1 次提交