Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1023558yba; Thu, 4 Apr 2019 02:39:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzglFwXlJKybraaqPC3x3ddg/xXbXAA/r/ruDE3INPI/RuJMzx1vW3SCQYCyanP9d5UILQA X-Received: by 2002:a17:902:1e2:: with SMTP id b89mr5392180plb.278.1554370781061; Thu, 04 Apr 2019 02:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370781; cv=none; d=google.com; s=arc-20160816; b=jExfrfVhoyK2knraTknye3it/53lyuw2ecvOHa/VAur9C1/V2q/xdeYOaR6SaJQg/r NGvunY9Quhg3GBQaEdJnuLjYPEP+Og7GHvaZSGpzvgFresepLhWhXHHULAjLAyM+UDEE mUnR8+um3+Gef/MKzGo8Fz9wYjibgRlrZrk/3kGOCm2NNPs1nzAu18AGejjjqhCbsAPo vIH2r1ZKoHyRF3jW1HImjwGD4dDRGqY/nJ76SqnDpmjrcJDeVtuUrmSMaQBFl2WF0uTs NVR8WYoMAeJVuJBp3COWx/w/hvJV6W4fDwfmHV6s5Jbv0UVoTOvpQKaRaG6FWsTlb3Sc yKpA== 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=u1886O1uzVT5chE1f/8K/2x0A6O1QYL33YL+T1uy+kk=; b=OVNC/KfC9YH5T7pkSV9QXRVj8rkNK3lWuVgPtHvViNOzJ2uartvfGb2CWOuMgteBQn F7TX0fsIbfwK+sEbTv/G9NciW9LhSOMihDnVxG59UjGLo7sAM7Gik2GGsDFuCqIusL+s iws/Oy9m1kajGb7tDcdULWa/evaUFKXTCqqTMeW2I2Ch1pw9V6o8eIDN4sNKgGB6wP/N BDdfFqqKUVpWXPsSLpyA8OelY2K5Vtg7je4DHI8SvKu0+AlannYNs5nW2AJGE0Mzp3f0 Bja2LL3jHkuUHzxJ9yYVquYQsj5ZiGo1gbOMnfbJ1CNQVnpOToiE+ks1K6eIVCWCZrjz Wiug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JZpsvoFp; 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 r63si16620643pfc.183.2019.04.04.02.39.26; Thu, 04 Apr 2019 02:39:41 -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=JZpsvoFp; 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 S1731886AbfDDJEC (ORCPT + 99 others); Thu, 4 Apr 2019 05:04:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731879AbfDDJD5 (ORCPT ); Thu, 4 Apr 2019 05:03:57 -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 DC51E2147C; Thu, 4 Apr 2019 09:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368637; bh=ZUotyxZFK6YExqSOu1ZLCHyzUfmdXp2U0stcDwhR3og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZpsvoFpDzXFAoPdkm+XdA2fK/o8Ew7E2Iivs020hu+lb8yZFw+Vt0GYYjky9QMYg fXQ/gvHrfEj8XzTKfxx8nb3bNJsIBxwXZjPm9wIOaF3Ug6xJSVDe6Ybt437k7BdXCZ myc7JHHRHTJqslS36Z6CRizbmIOw6k68Sib4/W9E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Kazior , Jacek Anaszewski , Sasha Levin Subject: [PATCH 4.19 097/187] leds: lp55xx: fix null deref on firmware load failure Date: Thu, 4 Apr 2019 10:47:14 +0200 Message-Id: <20190404084607.738768969@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 5ddb0869bfc1bca6cfc592c74c64a026f936638c ] I've stumbled upon a kernel crash and the logs pointed me towards the lp5562 driver: > <4>[306013.841294] lp5562 0-0030: Direct firmware load for lp5562 failed with error -2 > <4>[306013.894990] lp5562 0-0030: Falling back to user helper > ... > <3>[306073.924886] lp5562 0-0030: firmware request failed > <1>[306073.939456] Unable to handle kernel NULL pointer dereference at virtual address 00000000 > <4>[306074.251011] PC is at _raw_spin_lock+0x1c/0x58 > <4>[306074.255539] LR is at release_firmware+0x6c/0x138 > ... After taking a look I noticed firmware_release() could be called with either NULL or a dangling pointer. Fixes: 10c06d178df11 ("leds-lp55xx: support firmware interface") Signed-off-by: Michal Kazior Signed-off-by: Jacek Anaszewski Signed-off-by: Sasha Levin --- drivers/leds/leds-lp55xx-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 3d79a6380761..723f2f17497a 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -201,7 +201,7 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) if (!fw) { dev_err(dev, "firmware request failed\n"); - goto out; + return; } /* handling firmware data is chip dependent */ @@ -214,9 +214,9 @@ static void lp55xx_firmware_loaded(const struct firmware *fw, void *context) mutex_unlock(&chip->lock); -out: /* firmware should be released for other channel use */ release_firmware(chip->fw); + chip->fw = NULL; } static int lp55xx_request_firmware(struct lp55xx_chip *chip) -- 2.19.1