Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2393464lqp; Sun, 24 Mar 2024 17:30:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn8pK0TeJpt1Z/ahrSS2M75gqjnMTcykHudTCjrgEQO3S4HhXZzL28mUaNvdqC8lZm16e7Kcj3/j26D4KMReA2x0mjo3eJeZAaZKtvnw== X-Google-Smtp-Source: AGHT+IGiAgcJo+w8CSvZ7gEZX3wcciuvc0PhVU7ZcDUXYBcFihrUkf0daCThpE3lJ8RAaZBwqOJZ X-Received: by 2002:a05:6214:da6:b0:691:8b3a:5acb with SMTP id h6-20020a0562140da600b006918b3a5acbmr8009601qvh.13.1711326630929; Sun, 24 Mar 2024 17:30:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326630; cv=pass; d=google.com; s=arc-20160816; b=ycP7Y2wAbwvrMIzRM+xiJnWCpk6UoYLy4IZ5czDE2xRyoXOlShWdQz2QV5zrBvZ9+R C2D512SY5TtkBeGO/3baVt8PgDtaqWJMfVHPW+GK4XQKKdb+aSxT/byyB5QWGAWpX8n5 Q8bWBKGke0FShBFGah2n9NTWU9AtsOkJN9wHf9X8NDVZFz/4kf/BTgfcJbfXjygtOS95 ekr2HTWOX3yI83AKxtmvyIhc6hg/b7YPvACox1eBgI7F8zFA0sR/E31gBRUjifgUYlwS T/bZ2dpjBBuYI6u96pAcqXATqVM25NWJWNTv62qh9/UedGvVsLLfB0LT+47PBVRTw5eV ULJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uXs3fNM3CkCtz+VALsfM1ifYRb3v0OaT648DoPHP+c4=; fh=hk4TXR02PjD1cj2UVY+/gs5i9v2hd+6GU+f7qa4ID90=; b=cyIfsD59rhvU3X02OSwStV5D9SGKm1nag4rx9AF+Jg+mKIdPeWqfSCFyUFE1nEbUmg 05gOSiqZQIopWaKEGXy7r922ad2MXbZBpl1wnTj42kORLnT0SqgZAj665AuOS68Rudp9 /duZ6hIAqAPdiyP1XBqu7paWOfFkFDbMq1rZDQtSFOrmAJ5Rkqgz6tvTAr8vb2419NZG maxVsexEhWFKysX9kgLvn+EsqVIiiSR1BVS+9ktKDBN+Cmx6hrnrYkl9TRgcHBM7h9ib xx/mnQJNhhKXkjGTttfJA3ocYfr67VGroHTyvh/6B/GzWIk9ep8m/hIVg4nfWcW/thNp MuPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mW+0COhC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ey5-20020a0562140b6500b006961bba141csi7152375qvb.154.2024.03.24.17.30.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:30:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mW+0COhC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A31B51C23B8D for ; Mon, 25 Mar 2024 00:30:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EB011A704C; Sun, 24 Mar 2024 22:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mW+0COhC" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F86C1A7030; Sun, 24 Mar 2024 22:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320215; cv=none; b=nplpiB1iC4XdZ2IOJ6wY8Wj4ARCKBmfQrJi4CmPM157MbfSe1ZEX+3jnaTvXi1A3oET22WlVGvpjm1g2IvHQDbGx5YzjNAGBEzfhX9U9NfrROVoWp6qzLLnj13FjIGlOnSrNh8EhXXsjCN0Xi5gugfYLnQ3wJ6DlqZi7+mbwaIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320215; c=relaxed/simple; bh=j0Fk3xen+y6Fjp8MaIWIF4jWLasG0U8KGYm4HDJ18Mk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RePXJLl/zuKBUmF73sQHZbOo1jPuJA3ggoMaEM6DIcMoIqplb3/hV/ba4/bBXc9UD31dOez5pS9V/4CUEt/uolxuk7yO9QUB113KrI+ETVLaVZ7T2Clklm4slAcvftDGg+AbaSRRj1JF5fR6+DGjHFCcm8i46xJBmfP4Ld51EyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mW+0COhC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51ECAC433F1; Sun, 24 Mar 2024 22:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320215; bh=j0Fk3xen+y6Fjp8MaIWIF4jWLasG0U8KGYm4HDJ18Mk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mW+0COhCNXO0G5UJkEZH1ZENKtZhtuVA1ZMmV7I42orDdrw0UzMJZXGODG94nhODw a70wHoxPiBFv1qstgI75k/12xSgGxI2z9juPUflxNJ3YByVnyTPM/RdbswRQH39fZ0 nXjsSRVDimvTctqQjVTL+6t5hqn4SSSDzcC9Qme4Ip3s55YvI79of+9uhLGSokphYX aCw73lge4vjvhJF/QGMJijDB5Lz9hXnv6Bzb+q43yZBqV+OJqenVQbwlOxhoBebN89 FqVIONrciypZwlHqTWDfEKU1+L1boSI4tw05tQi+cNWnW+Oz5/0ukDtLk67k2HFgNF wF+LisI5GQO/g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andy Shevchenko , Dan Carpenter , Daniel Thompson , Lee Jones , Sasha Levin Subject: [PATCH 6.8 522/715] backlight: hx8357: Fix potential NULL pointer dereference Date: Sun, 24 Mar 2024 18:31:41 -0400 Message-ID: <20240324223455.1342824-523-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Andy Shevchenko [ Upstream commit b1ba8bcb2d1ffce11b308ce166c9cc28d989e3b9 ] The "im" pins are optional. Add missing check in the hx8357_probe(). Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/642e1230-3358-4006-a17f-3f297897ae74@moroto.mountain Fixes: 7d84a63a39b7 ("backlight: hx8357: Convert to agnostic GPIO API") Signed-off-by: Andy Shevchenko Reviewed-by: Daniel Thompson Link: https://lore.kernel.org/r/20240114143921.550736-1-andriy.shevchenko@linux.intel.com Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/video/backlight/hx8357.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index d7298376cf74d..bf18337ff0c2c 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -609,11 +609,13 @@ static int hx8357_probe(struct spi_device *spi) lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW); if (IS_ERR(lcd->im_pins)) return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n"); - if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS) - return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n"); + if (lcd->im_pins) { + if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS) + return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n"); - for (i = 0; i < HX8357_NUM_IM_PINS; i++) - gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins"); + for (i = 0; i < HX8357_NUM_IM_PINS; i++) + gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins"); + } lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd, &hx8357_ops); -- 2.43.0