From patchwork Tue May 13 10:09:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 4165211 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 04AE4C0ACC for ; Tue, 13 May 2014 10:10:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45EAA20353 for ; Tue, 13 May 2014 10:10:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 331AD20340 for ; Tue, 13 May 2014 10:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759891AbaEMKKq (ORCPT ); Tue, 13 May 2014 06:10:46 -0400 Received: from cantor2.suse.de ([195.135.220.15]:50666 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933234AbaEMKJe (ORCPT ); Tue, 13 May 2014 06:09:34 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 327A0AC96; Tue, 13 May 2014 10:09:33 +0000 (UTC) From: Takashi Iwai To: Greg Kroah-Hartman Cc: Jiri Slaby , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] vgacon: Fix & cleanup refcounting Date: Tue, 13 May 2014 12:09:27 +0200 Message-Id: <1399975769-30526-2-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1399975769-30526-1-git-send-email-tiwai@suse.de> References: <1399975769-30526-1-git-send-email-tiwai@suse.de> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The vgacon driver prepares a two element array of uni_pagedir_loc and uses the second item as its own reference counter for sharing the uni_pagedir. And the code assumes blindly that the second item is available if the assigned vc_uni_pagedir isn't the standard one, which might be wrong (although currently it's so). This patch fixes that wrong assumption, and gives a slight cleanup along with it: namely, instead of array, just give the uni_pagedir_loc and a separate refcount variable. It makes the code a bit more understandable at first glance. Signed-off-by: Takashi Iwai --- drivers/video/console/vgacon.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 9d8feac67637..9e18770aaba6 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -87,7 +87,8 @@ static void vgacon_save_screen(struct vc_data *c); static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, int lines); static void vgacon_invert_region(struct vc_data *c, u16 * p, int count); -static unsigned long vgacon_uni_pagedir[2]; +static unsigned long vgacon_uni_pagedir; +static int vgacon_refcount; /* Description of the hardware situation */ static int vga_init_done __read_mostly; @@ -575,12 +576,12 @@ static void vgacon_init(struct vc_data *c, int init) if (vga_512_chars) c->vc_hi_font_mask = 0x0800; p = *c->vc_uni_pagedir_loc; - if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir || - !--c->vc_uni_pagedir_loc[1]) + if (c->vc_uni_pagedir_loc != &vgacon_uni_pagedir) { con_free_unimap(c); - c->vc_uni_pagedir_loc = vgacon_uni_pagedir; - vgacon_uni_pagedir[1]++; - if (!vgacon_uni_pagedir[0] && p) + c->vc_uni_pagedir_loc = &vgacon_uni_pagedir; + vgacon_refcount++; + } + if (!vgacon_uni_pagedir && p) con_set_default_unimap(c); /* Only set the default if the user didn't deliberately override it */ @@ -597,7 +598,7 @@ static void vgacon_deinit(struct vc_data *c) vga_set_mem_top(c); } - if (!--vgacon_uni_pagedir[1]) + if (!--vgacon_refcount) con_free_unimap(c); c->vc_uni_pagedir_loc = &c->vc_uni_pagedir; con_set_default_unimap(c);