From patchwork Mon Dec 24 21:39:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Pakki X-Patchwork-Id: 10742413 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B073A924 for ; Mon, 24 Dec 2018 21:39:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9290F2847D for ; Mon, 24 Dec 2018 21:39:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8061828485; Mon, 24 Dec 2018 21:39:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2348C2847D for ; Mon, 24 Dec 2018 21:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725814AbeLXVj0 (ORCPT ); Mon, 24 Dec 2018 16:39:26 -0500 Received: from mta-p5.oit.umn.edu ([134.84.196.205]:52418 "EHLO mta-p5.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbeLXVj0 (ORCPT ); Mon, 24 Dec 2018 16:39:26 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p5.oit.umn.edu (Postfix) with ESMTP id D9A0A6C0 for ; Mon, 24 Dec 2018 21:39:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p5.oit.umn.edu ([127.0.0.1]) by localhost (mta-p5.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KwF02Kh-zbHo for ; Mon, 24 Dec 2018 15:39:24 -0600 (CST) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p5.oit.umn.edu (Postfix) with ESMTPS id A32485D6 for ; Mon, 24 Dec 2018 15:39:24 -0600 (CST) Received: by mail-it1-f199.google.com with SMTP id m128so15127816itd.3 for ; Mon, 24 Dec 2018 13:39:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=7RYsDfMgiAguPYV89izW8+HWY2mw1oC7VV4dg6eWvpE=; b=iPanVUxxGsqPMzEtMWD/Ifva8WcPRVTo/oHlSFzBOtTTwiCHoTxZe8N8pbYOQYprSc tnV1rzvMa3mP1iGiJuQ2+nKA24KxaCRw54WZWdAPLZNtvVnia19beVVzkW2xRceKNgBG DSMLC9Sfn+d+O83jUE2IXwCpyG3U66KSBWGgtUokyAlXQIZ5Mpu7glt2JxydfEihXzK1 VjjZUgyKtZnErWV+eXBOw1G72kfsC4M9GlMQU4xu0znNUyOOkwnk7nhu5/SGD/A/E9jx d74XPKpm/iWQawt0Y5L6xVCs4FVOGWVKDv75/2JuNlFqjdmLTOjLUZ/erFTiHxxsmgCx CqcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7RYsDfMgiAguPYV89izW8+HWY2mw1oC7VV4dg6eWvpE=; b=kVe2NKaeqGwoM3UJWVakA9vwopjWq98lmww8bQ9gXX5nU2NHHq3/po/+RqYHWUeUf5 ef7UCew3cedV7Kn0EV3OX72C3QROCGF/fy+JLZHKfSOoi+sykpFsO94jnO8/Eag1Epi/ V7+/kjetE2l5oCfEuOYLeIFYppFniBWbRd0XbDyFCjiAWjGrFWkWCKWJK0Kg5OV0CQfj 0esZfi52HsRDSyDBLmXKhgxxFC01jA1o0EaTaiJ4mIEf31YS5pCHRleGHx2F7i8yhwB+ whEcVrIUbjj1tOAbrk90fChqZs2ZyDjH9BbXEzMDzfS3z1ShD+onYCXptRwAsDCSTFK/ VMwg== X-Gm-Message-State: AJcUukeoZxUIiuFP0KYKwTrI4HMv+GpPtCRGclmabKdOsg4Cy2Uyujws SJLMPMy1NyS6K6MYGWn21zebV8c5ZArTwjBVq0mTwO4Kq40h5xSOeoDc5QBUIL9//59BEJqFqsk /X+cmEPHSMi2XZBnEv/h2cGhyF2w= X-Received: by 2002:a24:2e94:: with SMTP id i142mr10540090ita.157.1545687564246; Mon, 24 Dec 2018 13:39:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/X5nMH/x4zxNC40JrRJIKs7zITcDYOBrERJErHHnQuCw8Bnpa0uTncgRTWxvBoTSJ/NNfPVng== X-Received: by 2002:a24:2e94:: with SMTP id i142mr10540082ita.157.1545687563997; Mon, 24 Dec 2018 13:39:23 -0800 (PST) Received: from cs-u-syssec1.cs.umn.edu (cs-u-syssec1.cs.umn.edu. [134.84.121.78]) by smtp.gmail.com with ESMTPSA id m18sm3519105ion.78.2018.12.24.13.39.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Dec 2018 13:39:23 -0800 (PST) From: Aditya Pakki To: pakki001@umn.edu Cc: kjlu@umn.edu, Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hid: Add checks to fix of_led_classdev_register Date: Mon, 24 Dec 2018 15:39:14 -0600 Message-Id: <20181224213914.26453-1-pakki001@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);