Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2748708imj; Mon, 11 Feb 2019 07:55:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IbpA70uk83vfb7E66+tZWr3RyfS1SsTmpbgoJgiAQZrvSFIwdOFbnmG9vpcvX+UrvBcx70f X-Received: by 2002:a17:902:b203:: with SMTP id t3mr9625455plr.243.1549900537877; Mon, 11 Feb 2019 07:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900537; cv=none; d=google.com; s=arc-20160816; b=d/CpwppAOPYbOgLO25pFtr8fJqO+1+AqRBKrAelDLtqszirRr7wpaB4r11c3L3AaFc 43Wzgu2N2g7TZfEbPTtVLUAvRnROJMOS+PihNkt3GkiO5uu2SdtzomH822Eg/Ub+Ioci I4s7JsCFTaYEEZrXl5D0b6iS/ujB0ElOQGSvNCHCcF3F72Iny7xJtFXPiVEwD1kKM0OI +R2CVaAsgLg32VV7FOky1DASiZkLfedLyKgbyaK3+94ed2OYVt4IDJ5tH4+2KErI0ZJV szuJk586VDmUMIRzD0asonvE0CRFda1yVhypwHKpyKfL0UQhFtbX1HEYfXJdvvBJ00op DQUg== 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=FyrpVAUTPuF1RPM71THPjEFxWQT42JGBD1yNaOo0IZo=; b=JLGTIgTbtZhbItDUlPBI2mqjYPsronhhkIRhT19jmZHcQtBTnwTgz2Lsq0txcokeZX chXYeWQdA1/G3Gp/R5i7kyuF+KbTXfj8x8NJ+Ildm5NRKih/0nZSlzJZ6xi5Tuc1pLBP IfB8bW/U4JTBH8ESZ+ZZ8TAIZny73uq5BecbLo1ZC+/Do6Kn6dbQ2JxE9PhLCNj2MtW3 E30vVdhptFdBvsmBLRJXoJy1Q5MDVPTT8/DJ8rfIcRN4LUe6CB2B0QrULTq04kQmuKeL 4zqskYF447rKLU6TuZdx46XlPMLPM7QX/SHO4dHsO3Np0zVHKHpdQoB/EVJZt0c7qw2N 1Tgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HtW53J41; 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 y12si10228218plk.174.2019.02.11.07.55.22; Mon, 11 Feb 2019 07:55: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=HtW53J41; 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 S1730704AbfBKOfn (ORCPT + 99 others); Mon, 11 Feb 2019 09:35:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:44444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730650AbfBKOfm (ORCPT ); Mon, 11 Feb 2019 09:35:42 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 08DB720700; Mon, 11 Feb 2019 14:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895741; bh=J8TlKC2fm/pZ1DhdlWDC3is4jsvDUHZ2PDa1IZnGZ7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HtW53J41TWxDmRw4uHdFxoe7V+ySU+C1XWj2v+BRPBXgL48/tcmn6ROvet6H/1sQM PHc1/9t3gh8z2Xx4mftTL5lTow8L3aF7M9hVkJH/yA6qxgBujBJtbwc3sifFc7P/Ho EsfvXzGNs0nA6BYkNBgHuhyIs4EcCde6G8AFVi6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aditya Pakki , Jiri Kosina , Sasha Levin Subject: [PATCH 4.20 280/352] HID: lenovo: Add checks to fix of_led_classdev_register Date: Mon, 11 Feb 2019 15:18:27 +0100 Message-Id: <20190211141904.771751638@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 6ae16dfb61bce538d48b7fe98160fada446056c5 ] In lenovo_probe_tpkbd(), the function of_led_classdev_register() could return an error value that is unchecked. The fix adds these checks. Signed-off-by: Aditya Pakki Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-lenovo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 643b6eb54442..eacc76d2ab96 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -743,7 +743,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) data_pointer->led_mute.brightness_get = lenovo_led_brightness_get_tpkbd; data_pointer->led_mute.brightness_set = lenovo_led_brightness_set_tpkbd; data_pointer->led_mute.dev = dev; - led_classdev_register(dev, &data_pointer->led_mute); + ret = led_classdev_register(dev, &data_pointer->led_mute); + if (ret < 0) + goto err; data_pointer->led_micmute.name = name_micmute; data_pointer->led_micmute.brightness_get = @@ -751,7 +753,11 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) data_pointer->led_micmute.brightness_set = lenovo_led_brightness_set_tpkbd; data_pointer->led_micmute.dev = dev; - led_classdev_register(dev, &data_pointer->led_micmute); + ret = led_classdev_register(dev, &data_pointer->led_micmute); + if (ret < 0) { + led_classdev_unregister(&data_pointer->led_mute); + goto err; + } lenovo_features_set_tpkbd(hdev); -- 2.19.1