From: Greg Kroah-Hartman Date: Thu, 16 Nov 2017 17:41:20 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v3.18.82~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c037fdb5ea59650bee3528b7732c5b5298f68aa3;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: misc-panel-properly-restore-atomic-counter-on-error-path.patch --- diff --git a/queue-4.9/misc-panel-properly-restore-atomic-counter-on-error-path.patch b/queue-4.9/misc-panel-properly-restore-atomic-counter-on-error-path.patch new file mode 100644 index 00000000000..54909413f33 --- /dev/null +++ b/queue-4.9/misc-panel-properly-restore-atomic-counter-on-error-path.patch @@ -0,0 +1,78 @@ +>From 7ddfddb3fc0afb2aa36e89b554f06c901c5fa36f Mon Sep 17 00:00:00 2001 +From: Willy Tarreau +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). + +Fixes: f4757af85 # 3.19-rc1 +Cc: Mariusz Gorski +Signed-off-by: Willy Tarreau +[wt: driver is in misc/panel in 4.9] +Signed-off-by: Greg Kroah-Hartman +--- + drivers/misc/panel.c | 23 +++++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +--- a/drivers/misc/panel.c ++++ b/drivers/misc/panel.c +@@ -1423,17 +1423,25 @@ static ssize_t lcd_write(struct file *fi + + static 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) +@@ -1696,14 +1704,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) diff --git a/queue-4.9/series b/queue-4.9/series index 0e9fa09d77b..90a0cb0b082 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -36,3 +36,4 @@ security-keys-add-config_keys_compat-to-kconfig.patch brcmfmac-remove-setting-ibss-mode-when-stopping-ap.patch target-iscsi-fix-iscsi-task-reassignment-handling.patch qla2xxx-fix-incorrect-tcm_qla2xxx_free_cmd-use-during-tmr-abort-v2.patch +misc-panel-properly-restore-atomic-counter-on-error-path.patch