Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5224650ybl; Tue, 27 Aug 2019 01:05:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFAkc/7yDr9m9zKcCFEGXTwnA2sFuatWGkEnq5mVnnPsXAl6jgKBA+GYon5I8GVf4v40qE X-Received: by 2002:a17:90a:bf0e:: with SMTP id c14mr7804914pjs.140.1566893136158; Tue, 27 Aug 2019 01:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893136; cv=none; d=google.com; s=arc-20160816; b=AQ9ObWTOmxHOTiB432UuoSqgp8qpfEYP4fGlfhqXz0FRa87i15Xq1K/8AvkIPg95Sa iotW1rwLOCAKDrTM1kUW3gFSQpptNRwHbspitlUOL4m2tkom/7k6eH7SDd9TjqtMScTY DS5gvs0lO++8suKlW8QGygDkC2q9jHkwj1o3iX73yomqYR9WyoA9ODuaBrVNmeW9OjFi 4GbF1JBzd8XDj/68Khss6HBFURcnBKSepnykdETWhwx5H4nWUzA2HQGnegebPev8Ezds ynFUs7ExOBkm6U8RwkDRlDxkm/2qts0uAwB40e3kc8DaxVXES2/d36XOU6YbkcOtiw9c sxsQ== 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=PbgGcCAXMvf7x0ksvMSYhCkWf5pBworqVm03XToGGYY=; b=y0AhxKpjmJzc9Im3Lu/+YqydQ3qkEYAxgQHHqPcsfaVadl3T+HDjO2Fybh5nhWw36s 4Nl76dR7pdyLmKObRX8MIpKQF4jkX3XM0xy+Wioy2sKIz9N3wlnrOw0Q0iWPOQuoIPhU LJFNc2ZUmqfNT7Q4QUrQ763TtLAYbVcKzhvjqTAP4PKoSl7jP83TtqMlc4Uq4czmVvPQ QhgwKUuc1ExvmJeBP3cRBTfNIUcpdT+/ojy2jdtgseywJh0tzcQJjrCcSIlZzexfKZBm YMU3n0eXReZpw5xh3msMabPw4YF3q+RuDnihkNS6rl6oYNzZWmBYChX/Wp6Q/PVrMz/E Jvpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I7MepG1+; 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 u70si11462044pgd.1.2019.08.27.01.05.20; Tue, 27 Aug 2019 01:05:36 -0700 (PDT) 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=I7MepG1+; 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 S1732514AbfH0IER (ORCPT + 99 others); Tue, 27 Aug 2019 04:04:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:33652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732494AbfH0IEQ (ORCPT ); Tue, 27 Aug 2019 04:04:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 3EA042184D; Tue, 27 Aug 2019 08:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566893055; bh=ZggfT+JWHGu1siNVM/GePQqwV8dlcwldZQqu52ZGpr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I7MepG1+a6DZihSTuI/LpbzaHAVh47pf/ZEQnwPdLHX6JqjTKBwNZnFMP7Dm6qasx UQuKvJMe9DEiOjGGAgynWF5ULUZnV2BbeBk7cpOzR6Rl+/kw2XpEDAnZcvDCTXCLdI Xn+b8PHHAByoDon5iynRNuYwQJ2X/qDn9rUTf/UM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , "David S. Miller" , Sasha Levin Subject: [PATCH 5.2 063/162] net: phy: phy_led_triggers: Fix a possible null-pointer dereference in phy_led_trigger_change_speed() Date: Tue, 27 Aug 2019 09:49:51 +0200 Message-Id: <20190827072740.358896227@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 271da132e29b5341c31eca6ba6a72ea1302ebac8 ] In phy_led_trigger_change_speed(), there is an if statement on line 48 to check whether phy->last_triggered is NULL: if (!phy->last_triggered) When phy->last_triggered is NULL, it is used on line 52: led_trigger_event(&phy->last_triggered->trigger, LED_OFF); Thus, a possible null-pointer dereference may occur. To fix this bug, led_trigger_event(&phy->last_triggered->trigger, LED_OFF) is called when phy->last_triggered is not NULL. This bug is found by a static analysis tool STCheck written by the OSLAB group in Tsinghua University. Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/phy_led_triggers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index b86a4b2116f81..59a94e07e7c55 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c @@ -48,8 +48,9 @@ void phy_led_trigger_change_speed(struct phy_device *phy) if (!phy->last_triggered) led_trigger_event(&phy->led_link_trigger->trigger, LED_FULL); + else + led_trigger_event(&phy->last_triggered->trigger, LED_OFF); - led_trigger_event(&phy->last_triggered->trigger, LED_OFF); led_trigger_event(&plt->trigger, LED_FULL); phy->last_triggered = plt; } -- 2.20.1