From patchwork Fri Jan 24 09:31:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 232857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8E69C35242 for ; Fri, 24 Jan 2020 11:37:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7549C206D4 for ; Fri, 24 Jan 2020 11:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865867; bh=Wk+ZmpSEN5g7qxeVyMdC8je/0aEgQIF8oHS9ao4XKtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gYr8hJf+roqZIsKFKDoptj27eJLnfAFQVkVQ+gArxv71xWJcseNjWb/d1aCehjKvR xE9BoMKkC+HksvIBofHGqlLZkHmqYthxK7QcApjdu7MOaBHedgBrAk2SFfj4FpyHVt Yt606ViwK2ypcpTvYhI10cR2gWKrWMZcncI+sFf4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403794AbgAXLbk (ORCPT ); Fri, 24 Jan 2020 06:31:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:50144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388657AbgAXLbk (ORCPT ); Fri, 24 Jan 2020 06:31:40 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 A68D72077C; Fri, 24 Jan 2020 11:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579865499; bh=Wk+ZmpSEN5g7qxeVyMdC8je/0aEgQIF8oHS9ao4XKtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvHPsLR4n64Db6/Q0lV2I/KC0lq4UByaOp9ajUBFKA5nS2KnHZPC3izrBu7Y0Uut1 ilLqsvCmfGxWi6jpkub/W3IRrbNoNq21ZgiYRa2KvkzjHNoBNUSDnxzALf0LZI8pCB tWzBz0ZAjUxig7dlspPlCyNZzbEIdeosqGNN39ZA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleh Kravchenko , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Jacek Anaszewski , Sasha Levin Subject: [PATCH 4.19 545/639] led: triggers: Fix dereferencing of null pointer Date: Fri, 24 Jan 2020 10:31:55 +0100 Message-Id: <20200124093157.383168919@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oleh Kravchenko [ Upstream commit 4016ba85880b252365d11bc7dc899450f2c73ad7 ] Error was detected by PVS-Studio: V522 Dereferencing of the null pointer 'led_cdev->trigger' might take place. Fixes: 2282e125a406 ("leds: triggers: let struct led_trigger::activate() return an error code") Signed-off-by: Oleh Kravchenko Reviewed-by: Uwe Kleine-König Signed-off-by: Jacek Anaszewski Signed-off-by: Sasha Levin --- drivers/leds/led-triggers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index e4cb3811e82a3..005b839f6eb9e 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -171,11 +171,11 @@ err_add_groups: trig->deactivate(led_cdev); err_activate: - led_cdev->trigger = NULL; - led_cdev->trigger_data = NULL; write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags); list_del(&led_cdev->trig_list); write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags); + led_cdev->trigger = NULL; + led_cdev->trigger_data = NULL; led_set_brightness(led_cdev, LED_OFF); kfree(event);