Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2689987imj; Mon, 11 Feb 2019 07:04:38 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib50O3hfGPGFPk6cQPhbIs1OUA+6RrTARaRrrzIJWOaL/MV/+XwpsdTLS3YcCMLOPiZWRkY X-Received: by 2002:a62:28c9:: with SMTP id o192mr37659683pfo.57.1549897478767; Mon, 11 Feb 2019 07:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897478; cv=none; d=google.com; s=arc-20160816; b=c+nOQux0JCt6rJzI3fyr9chvgWEYdIrxbn28m6w+5RGMsqzyWiLXJscHkEYjJpOw5x 4k2TgN1icxKK2oTnG+HdzkNTb1sb9l/HNG3KybZxmgoY/LabYWT3+ww1jJYY/AtDMbwn YBmC9qlwvhXYkbwjpP2XZ48xQLOWMPAVQWFaNREV3B10h4hbvCV8CjFhceoD+Auku8oh yFCDkBPTby1pJ5pgpIdah+aN6cIWsv0Vm027S21L7Dh3sLoPZxo/hRjSEFgkl64uXUse E0ZzqnDQPiV2G2BVrB7Tf9izTB/sPCxlnMdUGCyMTe3vZwDJOK6837JDaIeI42rgpwhg 5kLA== 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=YGaqMN3rS2EGMHPs5QAj0Q77iTk9iG8uAe+mFSq+WPA=; b=P6kVMYOxdJr/+vayGqihhHMxwYDaG+UIGbp0urlRLjQv8zzVfdrfFSgVhTE8b0o/dc 969RqH2iU+IANogk12/Tk2Vxt07SEnJcW5X2GI16F8Y/q2cfEJZ7zK1oBrZkoL7VNGjb NyNjJRD3VxIdsVRUP6cwiVlMUtYyxsTLsQcEsjhvWJkaR33h3m65TTIDLS89QJkDUwJA i//7ktwKSCGgEK6Ig0bCjU5nSvPuJ0CazC5FURtDKqOkaCyPrtp+y8FDbziCV6KhtJOT BgCRowTfMsiVtoakSSV/6QJf4SNGPOvHXziU6d9yemHNuPveukmUvMouVK10VMnzjGBh aNfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MIij9j4l; 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 l18si4888868pgh.511.2019.02.11.07.04.20; Mon, 11 Feb 2019 07:04:38 -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=MIij9j4l; 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 S2390583AbfBKPDQ (ORCPT + 99 others); Mon, 11 Feb 2019 10:03:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:51622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390514AbfBKPDN (ORCPT ); Mon, 11 Feb 2019 10:03:13 -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 0A3D0222AF; Mon, 11 Feb 2019 15:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897392; bh=eYxbfrMWzhJTkOuQgVO2uOOKR2lCRomPC9RrlQHN8YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIij9j4lw6/ciOEHv2jL/z8Q9dOa+PJTO1Xf93zMk6XRZD7u46EusBgczvAsPxAwr ucuJBXVpd6AVW17QDFnKRfCVL7txnIgpUV0VA7usTV2yZoZWDJT5RgZEn+IN7RoDY2 ggtghi8R8z7vWnd3E51GGQ5z2yFEz6XFqSFUFYVs= 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.14 157/205] HID: lenovo: Add checks to fix of_led_classdev_register Date: Mon, 11 Feb 2019 15:19:15 +0100 Message-Id: <20190211141838.625084279@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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