summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMattias Jacobsson <2pi@mok.nu>2018-10-16 15:20:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-12-01 11:16:37 +0300
commit283d9618e22b7ff43ac6fc16c35f3c4d24fbb733 (patch)
treebdb7e3c964060665ee93001e95b09038678aeada /drivers
parent80a23f70d546a6fc74561ce7f9e4e65cb6580791 (diff)
downloadlinux-283d9618e22b7ff43ac6fc16c35f3c4d24fbb733.tar.xz
USB: misc: appledisplay: fix backlight update_status return code
[ Upstream commit 090158555ff8d194a98616034100b16697dd80d0 ] Upon success the update_status handler returns a positive number corresponding to the number of bytes transferred by usb_control_msg. However the return code of the update_status handler should indicate if an error occurred(negative) or how many bytes of the user's input to sysfs that was consumed. Return code zero indicates all bytes were consumed. The bug can for example result in the update_status handler being called twice, the second time with only the "unconsumed" part of the user's input to sysfs. Effectively setting an incorrect brightness. Change the update_status handler to return zero for all successful transactions and forward usb_control_msg's error code upon failure. Signed-off-by: Mattias Jacobsson <2pi@mok.nu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/misc/appledisplay.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 1c6da8d6cccf..39ca31b4de46 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -148,8 +148,11 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
pdata->msgdata, 2,
ACD_USB_TIMEOUT);
mutex_unlock(&pdata->sysfslock);
-
- return retval;
+
+ if (retval < 0)
+ return retval;
+ else
+ return 0;
}
static int appledisplay_bl_get_brightness(struct backlight_device *bd)