Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3637900imu; Mon, 28 Jan 2019 08:13:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ZQHsxKEVsizIAumYqobAlfHkwkEFh/q9tbG15lEMuweEUs7vJVLi7ZfhHReDS8G7vR+0o X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr22124166ply.4.1548692039745; Mon, 28 Jan 2019 08:13:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548692039; cv=none; d=google.com; s=arc-20160816; b=u5/sR3BmSNkTCnFFPbR1FSVLmbaobtu0nJC2fvg0PhJmIhXS0hnMiQ2PBkSX/nuaDJ SIowhIz5QrH/U6FcqzCTrPMtaOtz7B+8LlXyd61/4pd+cuwEvtjz8LpoQz9oBaCs877Q 7djRleJ9LCQaR5os6ytTgSq6qEUFF7muKur9DbWqouJYySvrWOZiOX4JITblrDEIIAa4 +EN65Br5tbzHfuO5bSHtIIdf2GiJvOuaKbeOsa4X1rQKJZOXOo3AJ4xP5jxVb5Up1ogX BGamB3ahpeaquGiJgspaIYU5N8X8jHs/X+S7O0WSOaA4d0xo9AZ8Jaw3t/RoXVnL6yG5 jKRw== 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=/S0uB4+dn0gbwg0o5a3BInCNQQT9Co12VfwKAHYiA1Y=; b=PBR7nFFEC8RNCtBeBH9yWY9er9C58ztN50Vo54yX26CF3LO2YrmkztTCSvaUrkjaz9 K14t9TlOPpq3P9efbt5Nnztud42VGlML0/UoquWXLm26RknAwi1YZlcmgYlXiajniZXr NZfvy7dIuYm33UoOvIx9ruvrg5YnhV0FhpidOvj2rM8vwEcU4wWQpVwg/ER/mWHrdVFS SomLxq6mdT+U4AtwATHzGyZFk8fmrWX1s83pR0IGYH/DwosIwSwTT+48F6HgHzFyviMP HHtRhhWqdbfI/tNcn/IgQr7AKrLIvjSrFwE39GR3GN9xrBh/Qd7HCxGi7LsX2eMxEyey UYxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="oY/8VXRB"; 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 p22si32482643pgl.340.2019.01.28.08.13.41; Mon, 28 Jan 2019 08:13:59 -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="oY/8VXRB"; 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 S1732974AbfA1QL3 (ORCPT + 99 others); Mon, 28 Jan 2019 11:11:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:38450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732963AbfA1QLZ (ORCPT ); Mon, 28 Jan 2019 11:11:25 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 9254121848; Mon, 28 Jan 2019 16:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691884; bh=aHTiA+VvQMHT5liIyiq5RQlij9mEPbBTiOUj6/+qoRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oY/8VXRBds3XvOQaHuwmMoW/Ir69Sw1n85/fggKdE2qAf0OfNT3BQz3umz43mYr0W I7zzLUXFwuDe0xActVDIMiEkqLBotso7m+AEhp5i0YrynCWvR3CMvfjTjTN/Fh07FT vidwq0N5SmYM3WZypDEp5QSDm5oUdXbxuaNQUGqQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aditya Pakki , Jiri Kosina , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 249/258] HID: lenovo: Add checks to fix of_led_classdev_register Date: Mon, 28 Jan 2019 10:59:15 -0500 Message-Id: <20190128155924.51521-249-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 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: Aditya Pakki [ 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