Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5647809img; Wed, 27 Mar 2019 12:23:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqEfJecuEWSTKvNX/0g8aO0xGvqezZrg6PMmVQckatU6Y2Uh+g8UpvMqkk4rst6r0Vhi3R X-Received: by 2002:a63:470a:: with SMTP id u10mr36743279pga.17.1553714622324; Wed, 27 Mar 2019 12:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714622; cv=none; d=google.com; s=arc-20160816; b=Uto3U6BIEH4Oawr/KZfGlx5C03+wDdB1TR20lxM8LZ+uT+xvCRpJY+V30PUrkoUsMm aOOUmhcNF8nF2AMVA4b65IGj/s/H/Gknf5fxrqP8EEvXT6Mg+43n7c/5qA8xmvkX9J1n OVFDYZv4rQfn7hkwEL5d+jbJzo3kwfIRjVZM8Be0EGwUIX/EFY+7qirKlajwOQXBjjbb 2oeCajzJS/6ibUEdLFhWu9I7nK+5CzI4ouJ7q6vxfg3S3Z6dT95XI5BWI5S3Hj85fR0E +Eu/HJTnLR8ReiY7DC26P6Yp7HPmlq1EIMLh2sJrN8tVt5ZDN50oPlmpFpEfB0+vdsCA zw9g== 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=xYKUUF5X8NG+HEpBUJg+/s4+v7wywYx+bsmg7rh1Dec=; b=COFp77049qUKl6KPDyQuTI4IlPz1uX4hvat9lJgVoJMVk7o/E1OwYDojKdkD2snqli aBpMRLCCqvB5zLYI0i2J9z9lQsQtExbon5GCuz0Tf3fKh8MCp7SDq/dhwZuU3DAVeXVM jYwAmBP2vZAEDCNy2UB4CDyCd9bGpAq5bi4+PrWPrZoQrbKWeYM+AYwmWPXVqKWHwnEy ewGKXDk4fOxnSs1ftvqQO4hh8BvyQsQVoWzUoWjAI62W9tOl5oMm2i4hsaKHqqDDH6ip ifJOGKFvsPW0x9d2dLmRC8UUefzzsfrf8YK9RLmTbRv3+g05Obq259EYF0f2r9zhAJLn sPIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OIeXel4C; 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 a4si19147416pfj.17.2019.03.27.12.23.27; Wed, 27 Mar 2019 12:23:42 -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=OIeXel4C; 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 S2387751AbfC0TW4 (ORCPT + 99 others); Wed, 27 Mar 2019 15:22:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387875AbfC0SGK (ORCPT ); Wed, 27 Mar 2019 14:06:10 -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 A1BAD2184E; Wed, 27 Mar 2019 18:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709969; bh=3y6ZGrr09NCWKEneNnY47Kffxmq9WANmbRtWaEDcb8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIeXel4C6Rf2rOCJnPwKQ9ZmANArjZR2p9gokH0yT6ArkF5hVstg+BIpXRsDcX5Zc heTsXE4Jm99MQogvbv6oPUqwESckfgJoRv4d7nczv2lJ12Kk5HuNlUthUtJN/w7i81 /H6nlfvkkYkc6jAwKBq/LqjKfroK/FQ9RCv4iXu4= 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 5.0 138/262] leds: lp55xx: fix null deref on firmware load failure Date: Wed, 27 Mar 2019 13:59:53 -0400 Message-Id: <20190327180158.10245-138-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 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