Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp773420ybc; Sat, 16 Nov 2019 08:26:23 -0800 (PST) X-Google-Smtp-Source: APXvYqx2IyOqj26mH43rWEDQkcnvXHRoOsRca454E70kSrdrSc/wEKyNzgF6xu3UOOzKSfiqdmIR X-Received: by 2002:a17:906:9481:: with SMTP id t1mr11292568ejx.0.1573921583373; Sat, 16 Nov 2019 08:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921583; cv=none; d=google.com; s=arc-20160816; b=OLpQ3xFgK0zImFmKdZ87iJv907HbgDNhtIa9Qj+rid0jcOcrE/hM4lQG81BwKg8HpT ttwV9DWfECZ4mSYUZGExoaHLkVlUygVY4xWv78/Zoleoy5ceFyAWMAvlEpXwx/zebKX8 /1oSdq3jNJFpdwvoc+5Mc71Dqpqgxcr2kXuHyr9e0qsE1yCP51y2VnhWOnWuIpWYmsgT qtDfIMH2lDMoDWN26VxYXOeMm4gLfBi4bimBokyxHumorYHC43yh75gJkZ8JCKM/HGSm 8lJhSCtSd4OFYLYtAnRvjpMg62MHCQPPxp/SxoR60U3emgJE5xB5zHDnuOzJoBq8vhHT 1WcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0MNutmwJheeOV2TOmqkhA5CkPJQK8kzqmuGxJXd1Ds0=; b=MCcJZl4Gf89rtr+DlLHjRiWTh9uUB5fYtyFIgkwkm6p3Inf+SGnbAPG7h2cW5i3KwW vmo1b5MzQp+NDui7KhfnJuj+5cZzpfJa8Sf6AZH3Gor6twPL8FICVuvmfAYyPQQTv6v+ XVoOrUYS0bo9GMh3+yLYw7+5496CgbqLPvyCGvEC9gKWPUiG5tITHiYQAIfeNxjwkIp6 dgiGXhVbVPA7p7+F3kt1B3Wget7LDvKv75fbo2HQhyGjXRElleY7nrQfTN+r/a48bvqj 8eTPW58dWU29aX3sWl99bI77I9WjFiUtlT29LnGxOSmK3pn7tL/hA6eSok2oQU2sB2dm X6sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MLhbhzue; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si7531463ejj.70.2019.11.16.08.25.57; Sat, 16 Nov 2019 08:26:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MLhbhzue; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728466AbfKPPmu (ORCPT + 99 others); Sat, 16 Nov 2019 10:42:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:46436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728394AbfKPPml (ORCPT ); Sat, 16 Nov 2019 10:42:41 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45E7B20733; Sat, 16 Nov 2019 15:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918960; bh=FsvQRTDHzkmyfaLsTy8u40CfgdoIRfi8ccBGcX4mt+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MLhbhzue7t/GpDkcejpU+B/Wq4Qs5LpyUwOT9d7kASgTXPr7GIwUGcyE0ezfxab5J W/EXIYBwueTElW/etUSlv/aqCz04A1iDA6PbhCM8ZS5JgCu1gYPIMGm87dYhvVvRdV /YESeWkhzDeMFaZVepgJZI37ktUuNS0Uw4eWws9g= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mattias Jacobsson <2pi@mok.nu>, Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 077/237] USB: misc: appledisplay: fix backlight update_status return code Date: Sat, 16 Nov 2019 10:38:32 -0500 Message-Id: <20191116154113.7417-77-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mattias Jacobsson <2pi@mok.nu> [ 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 Signed-off-by: Sasha Levin --- drivers/usb/misc/appledisplay.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 1c6da8d6cccf8..39ca31b4de466 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) -- 2.20.1