Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5614007img; Wed, 27 Mar 2019 11:44:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkO1xFdLJKh2Il1hEwCuXO2OFDaVzdrOPZobNSl9ndmKhWP86QWe9Cg4ls4J0Vz/DhG7mN X-Received: by 2002:a65:424b:: with SMTP id d11mr6585603pgq.205.1553712254299; Wed, 27 Mar 2019 11:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712254; cv=none; d=google.com; s=arc-20160816; b=lQ4NggvLU1zNeHECqFtMa5QnmVcgQAlQeP7tuW8/RH2iklEYRjddk+f6MhbECFFaX1 pOc5kKqpIDYNv41qZmvr8PFlt3fQSSoAXL23EDKZtbgh9J+ixN/KU4c+mIJmbwIfKd6X aHLjp6jiyEBvHQOzW1BpIfL+Va+zCciKGOaEqEZM4xdRIsTFCf+So7rlIA3lfhRPGJUi FakBaiegHxSUq1efl0HDNewc8af5TZhb0lYxRq03sN4GMr/iw4jgdP9Ku0/LTzx/7JYd o/bYHRI29Ng3OPpz1J7oXMV9zCOsYdQSJP95MhMuv0tkc3PZ0kdkTHT/+xt5X3nHGsgM WePA== 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=LbdSBO73aaH7YYffcUFpt7tNGuNDCzj/yw/DCBqH6nU=; b=qml3U94TxQ70z8TZrZpJjastAXHjFvwNgc8orBlIFh/M8MHGEYS6EGn4PkyTffqMex WAnHbWcKLDbhijX6EobQUQmSxIm8UTmqQ3y984CdwAFcqj452NMrOudYXb7jDTBKgmKi 25eq7HGhvXCaMlSPPjArY7SKHCu/JaG0DEl4fjsOFwNFQQQTRTbxTOdQgBlw5FdigcRm Pg4PCFebLyxha26NONzVSZOaCNudCQawnrrg9iYhA8/wviW6ehE1Nes4vrDjSp33bMD8 YvpFrEcf3NUYMYUlX9YiIy9c8nkOhiCNW9wjMa/Wegv1WbMQWZ823gEgJrMsM0IzJrZR kuOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VTXlSteV; 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 n28si19070433pfi.109.2019.03.27.11.43.57; Wed, 27 Mar 2019 11:44:14 -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=VTXlSteV; 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 S2391048AbfC0Sm2 (ORCPT + 99 others); Wed, 27 Mar 2019 14:42:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:39948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390445AbfC0SV4 (ORCPT ); Wed, 27 Mar 2019 14:21:56 -0400 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 4DF9A20651; Wed, 27 Mar 2019 18:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710916; bh=hD2RJPnaS6Es29brTXoGgh69te7zm5LCCsCvee9+LEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTXlSteVgD6qzWJ5i/R+THI8dvVpmQ59N3vUsEPvSP8H5b0A3XLStZ/POq2SZLJL3 Eq9k7dB5/U01lcCbcYPy/2/tEfmMBon+bw6JeA9oimvrWl0QF+ft0DU7LTdfAGc6M7 rsIkZxg8ocQkQ3ovrRfhStKFI2mUrkgyPzpjva5Q= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michal Kazior , Jacek Anaszewski , Sasha Levin , linux-leds@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 45/87] leds: lp55xx: fix null deref on firmware load failure Date: Wed, 27 Mar 2019 14:19:58 -0400 Message-Id: <20190327182040.17444-45-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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: Michal Kazior [ 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 5377f22ff994..e2655953667c 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