Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5991451ybc; Wed, 27 Nov 2019 13:02:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwSUrYE82cJpluge38sCaCuuyiK9vL3t6jO+es/lVCoEHOt12bQW3Rwe5guaMQi2hYT19kR X-Received: by 2002:aa7:ca54:: with SMTP id j20mr4826642edt.179.1574888557210; Wed, 27 Nov 2019 13:02:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888557; cv=none; d=google.com; s=arc-20160816; b=Ip/sPdA6jACMcA+L3zU9HzN2pSW7WgQfz1S3luyK7oXjnl8eU7zrn8JMk9UziS98wU uDNDUk10n4tGf5/rFPg9zgtbWInLY+3rch/IZAYRUglCE3hExL/+JgQPTU5HdedwF+Hd w9wHZaCd4G5e4tyBjj0mWCYWdia+cOSDEiJhdM4q0H6Al6XOrALXtIMqPk5YvGua8rFH 7bceO0s2W9KQXgZfAU2CCczO4WI5EnqNln4KSqboBDPho6sgotKZ4drtRKijKN/m/jUr 3ZJvEeYReKABlTw4gtTQr7HpRdKUSD1j/wJQO91DD2VB3sUZkgwZoTdRpWFGzCfxFru0 pROQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0MNutmwJheeOV2TOmqkhA5CkPJQK8kzqmuGxJXd1Ds0=; b=wEHRPD882OHR4WnU9ccNv9pEyHLuMVDWJDGFpqkAemAcMOOD8dXo/CmHO+nKvEsGpP HggLOLBSRuaR9CZDXuEWHXOqfTSSc5W+OBVnvAd4oWPmzhTN+5/ZWFMy06i9mMikyjzi +tBBTaVlgtWMy2ECUIFckzVtyQYMbkQrIreEcdpE1BrH5rcEoptMdWvYICzQh0yt/+oS sDOWWIWF4pxZsPTr36MFYLWz072kdFlrepFcqghFj/highWY26pQnKu0bJxpm9yWt9YV c5u8XVjiGtDKi9boYBPgdllk9G98XQYnpzHLqliaKR30gLn/hGtK81vbD9e7X0WRf95/ I11w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KvxmAiJ0; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dm19si3152038edb.214.2019.11.27.13.02.12; Wed, 27 Nov 2019 13:02:37 -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=KvxmAiJ0; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731694AbfK0VBS (ORCPT + 99 others); Wed, 27 Nov 2019 16:01:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:53382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731688AbfK0VBQ (ORCPT ); Wed, 27 Nov 2019 16:01:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB70F21555; Wed, 27 Nov 2019 21:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888476; bh=FsvQRTDHzkmyfaLsTy8u40CfgdoIRfi8ccBGcX4mt+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KvxmAiJ0EXgQS8ci0x4zeJ0IS+CnfdQTyIO+ppEUnIvLeKcz0Lrh8GjiRVFlgR33k jqgud1wnimBwIzR4TWbwMzKwPZLctUbekoduqMllcYszaQeV1GP+DYz44y1SsEa1HV YYNonP5IoUAnJeAorGbAOR5SGnGEA/+YJ9g1bnJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mattias Jacobsson <2pi@mok.nu>, Sasha Levin Subject: [PATCH 4.19 096/306] USB: misc: appledisplay: fix backlight update_status return code Date: Wed, 27 Nov 2019 21:29:06 +0100 Message-Id: <20191127203121.908875694@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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