Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3929943pxj; Mon, 21 Jun 2021 09:35:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykX11y6jrvahtBfmOhZuoXGz8QCuFplA3r0QfeKyR7IdlWCe6uqPCjAd7gjz9NG/apiVoL X-Received: by 2002:a05:6638:197:: with SMTP id a23mr18069215jaq.77.1624293346585; Mon, 21 Jun 2021 09:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293346; cv=none; d=google.com; s=arc-20160816; b=sD12j74egRfrGIXHjOCSJOOgFjjlDyqJMB8wxC3P18cc5Olm/D9CV7zvPONhizcNdf 1cF23vSU/bbJQXkeZ1O/VEIwwg7//icm0MyCXrnplMRbVju2JSHLNxOBg7o//w0q4SLd aRURBv83g3Gopd3W2M5TE/7Ok4UnGGPVCz0kt4GLGQuiamQNpSZZvLYP4/qxW9mde4Fb JvhqWaIYNhcMSqY/8JnLYOQ9Mjbr7sJxzfx8WKn9Q5y6S1YUXdGJD3Gtnq6ZwnfX1jtR o8GUN9ZPet+Q+w+jkIlUoL9dafwBb1RkjrC/zZ/n52zSlF7DWgcu9kcPy8JskJriucW9 ispw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e4+uwu90SmMLaohXdIMOOwwMqEYjsK0cjwQvziXRUDI=; b=qvUHC35ymslKbjXjbif1xSajsuzoBLxtJuAq43RX4rCrG4FK2zfdbJUKcGvym3Uj7X UHQyN5vXdEsa1y+aDQ0ccgz9Y4/Cmuchzc2uJKYmMgBan+14gTw3qgSYwjCoDwxUV6BD NxLsmFWey1xw1JmYB2ksVch09vxV7jHOnADis7yO/YO8O8KJW4DqureokoDARimTbrP7 nmOOlrSZxoRZAOK9nw4QNkK0ZiVhTbmp2BNVCz9U5NEdPCVB26wvMJAyKKTH7Dxl2ZGh j7k2l2AgKPLdSZ/u552/Dt+mKirYZWXJtTci/GA7ojsnHvGqMlleSGizRj2+Q6ctHPpP WSLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nd8J4qP6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k24si21212309jan.49.2021.06.21.09.35.33; Mon, 21 Jun 2021 09:35:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nd8J4qP6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232371AbhFUQgQ (ORCPT + 99 others); Mon, 21 Jun 2021 12:36:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:52804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbhFUQcT (ORCPT ); Mon, 21 Jun 2021 12:32:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 174DD61357; Mon, 21 Jun 2021 16:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292759; bh=3LWTFrPqZrRejivSLKDXE5jWosmTTHgrAR+hU/+DOrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nd8J4qP6dA7ieFYwUkhEqBpbQ8qsKorCTIwDZx4Lgu6fZ7qzLSLlePW1ro5Sm40QD I6akCRl0iUtv1aNNB+lRnOmwHnyo84EDsEaVYMQK73K18e/Nd0XD+BK7NWPt100lph vYukfi4wyG4mZRgGY0AhUXMecQNfgQU8i4r9X8Zo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Axel Lin , Mark Brown , Sasha Levin Subject: [PATCH 5.10 086/146] regulator: rt4801: Fix NULL pointer dereference if priv->enable_gpios is NULL Date: Mon, 21 Jun 2021 18:15:16 +0200 Message-Id: <20210621154916.534198584@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Axel Lin [ Upstream commit cb2381cbecb81a8893b2d1e1af29bc2e5531df27 ] devm_gpiod_get_array_optional may return NULL if no GPIO was assigned. Signed-off-by: Axel Lin Link: https://lore.kernel.org/r/20210603094944.1114156-1-axel.lin@ingics.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/rt4801-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/rt4801-regulator.c b/drivers/regulator/rt4801-regulator.c index 2055a9cb13ba..7a87788d3f09 100644 --- a/drivers/regulator/rt4801-regulator.c +++ b/drivers/regulator/rt4801-regulator.c @@ -66,7 +66,7 @@ static int rt4801_enable(struct regulator_dev *rdev) struct gpio_descs *gpios = priv->enable_gpios; int id = rdev_get_id(rdev), ret; - if (gpios->ndescs <= id) { + if (!gpios || gpios->ndescs <= id) { dev_warn(&rdev->dev, "no dedicated gpio can control\n"); goto bypass_gpio; } @@ -88,7 +88,7 @@ static int rt4801_disable(struct regulator_dev *rdev) struct gpio_descs *gpios = priv->enable_gpios; int id = rdev_get_id(rdev); - if (gpios->ndescs <= id) { + if (!gpios || gpios->ndescs <= id) { dev_warn(&rdev->dev, "no dedicated gpio can control\n"); goto bypass_gpio; } -- 2.30.2