Patch "misc: panel: properly restore atomic counter on error path" has been added to the 4.4-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
misc: panel: properly restore atomic counter on error path
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
misc-panel-properly-restore-atomic-counter-on-error-path.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
29e391ca59d60b7902b09ed11edbc5c95c372f09Mon Sep 17 00:00:00 2001
From: Willy Tarreau <[email protected]>
Date: Thu, 7 Sep 2017 11:56:40 +0200
Subject: misc: panel: properly restore atomic counter on error path
commit 93dc1774d2a4c7a298d5cdf78cc8acdcb7b1428d upstream.
Commit f4757af ("staging: panel: Fix single-open policy race condition") introduced in 3.19-rc1 attempted to fix a race condition on the open, but failed to properly do it and used to exit without restoring the semaphore.
This results in -EBUSY being returned after the first open error until the module is reloaded or the system restarted (ie: consecutive to a dual open resulting in -EBUSY or to a permission error).
--- drivers/staging/panel/panel.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/staging/panel/panel.c +19 -4
@@ -1431,17 +1431,25 @@ static ssize_t lcd_write(struct file *fistatic int lcd_open (struct inode *inode,struct file *file) { +int ret; + + ret = -EBUSY ;if (!atomic_dec_and_test (&lcd_available)) -return -EBUSY ;/* open only once at a time */ + goto fail;/* open only once at a time */ + ret = -EPERM ;if (file->f_mode &FMODE_READ )/* device is write-only */ -return -EPERM ; + goto fail;if (lcd.must_clear) {lcd_clear_display (); lcd.must_clear = false; }return nonseekable_open (inode, file); + + fail: +atomic_inc (&lcd_available); +return ret; }static int lcd_release (struct inode *inode,struct file *file)
@@ -1704,14 +1712,21 @@ static ssize_t keypad_read(struct file *static int keypad_open (struct inode *inode,struct file *file) { +int ret; + + ret = -EBUSY ;if (!atomic_dec_and_test (&keypad_available)) -return -EBUSY ;/* open only once at a time */ + goto fail;/* open only once at a time */ + ret = -EPERM ;if (file->f_mode &FMODE_WRITE )/* device is read-only */ -return -EPERM ; + goto fail; keypad_buflen =0 ;/* flush the buffer on opening */ return 0 ; + fail: +atomic_inc (&keypad_available); +return ret; }static int keypad_release (struct inode *inode,struct file *file)
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/misc-panel-properly-restore-atomic-counter-on-error-path.patch