Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp60292rdb; Sun, 14 Jan 2024 06:39:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2aTRz5JV+zL5DMYSLiCD8KGZyDGcJiQdkqupnTjZgJhsAGvyww5Bm8Vpb44VSz8rbXpWL X-Received: by 2002:ac8:5914:0:b0:429:8aa5:948e with SMTP id 20-20020ac85914000000b004298aa5948emr5676329qty.70.1705243178072; Sun, 14 Jan 2024 06:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705243178; cv=none; d=google.com; s=arc-20160816; b=oSy/E40j1WBep9mtf/J1B0dWlq3s7PlKV+XprVA13xC4DbH1BRj4Qyv6Wc8UMSw88w oIB8h0u0HQUN6iNAhTned7RNqyItuGo9rPTO1GfGN3O3LvOAKJ2XHFp0jC9bwIG4s2x5 xRQMAPD4OUGVONN7EITjjVMLcNmio0RqbpOZiqSMAhVHinzNw0/w7t3NSNBs2OL03oEf XtlseymQRf7yHiDU6RjiYtvzGaMX7oxJIVeXkKOdO7OIywiw3cviRmvUHTHkT0JbmsJU DbyDKWg0xEAFjJX16NezhKWyGko3Cx3+a0xzpU52yVB2yw2fnSRKU3erm6LMLbAZXr3f M6lg== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ZWPKFPvCjloAJr36s30cwgn5WFmkyLJh9Y/IldW+kLk=; fh=2/2D7tqectwNYgc4RMgslV0Z9qiu1K1gcXnmYvS6Lbc=; b=SW2qP1Dzjx86OKUkThYobiG2W7chsxMOT1XTIDJ+jxeMaG+VSp7XxN45e+DjBxN1SN Y8r690v+olqdeH9Eb3W2ul27Mjz8usdZMMef8r9JpKH+nj1qiM4LuwWyQGsNq0WGVF9D PCqfNcToEi+tKpjOorSgqdkbeV9iAEPmWQqrRUti3+398403FogJfaqUZCdh4Yxj1n5T vHqRHjfIxbBY2MFHHrTEAgKNmX8y4uE4H95Ovak5Ff5kA2TM6o20b2oYMztQZW8advLO aqSqI3cVGc4Cvpzmwc5rP03C4sElx0LQi9O4Dl4mDTaSCEZFsFMSX7KYDv2XZYWJgySa ozxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GCu70Qar; spf=pass (google.com: domain of linux-kernel+bounces-25485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e14-20020ac84e4e000000b00429e30bb96dsi1636327qtw.30.2024.01.14.06.39.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 06:39:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GCu70Qar; spf=pass (google.com: domain of linux-kernel+bounces-25485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 CD7F41C20BAC for ; Sun, 14 Jan 2024 14:39:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58C082109; Sun, 14 Jan 2024 14:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GCu70Qar" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (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 E1EC92100; Sun, 14 Jan 2024 14:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705243170; x=1736779170; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LjxdR67V7tYCeQiHxVhdjSjgVoL8PIzrrKcwukyWZSQ=; b=GCu70Qar8nZTPI52VrH3J2cjzmtQ634TI8FW6ZWDSW5b8BnZ12+H5MA6 G+XO2mUrLSiRh27jBeJp2cOI3R9sNd26ULTbKFiaRGgHsEMFCGkQigewZ 4DWDhr6rNgyYBYTHuDv0OBh+y2GqG71nPT6WJsVX8aV+vwsvcY9mdcUId S8beCJm0cO5cakkHVeAbWt0Dxk7rZNPPK5wxF1ToR0mKWvz0EaYZIk4nq mSc6ywpR+sdX/JbwcWUxe63m0QK/9op/7AcjAuo1u/8ufqLmXuydAQT8G +8MOZLamgISyvzAETfWd0f9PEfc5MrZg/7EspqEvIxmW0Sxues/cbIzkF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="465845314" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="465845314" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2024 06:39:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10953"; a="1114692658" X-IronPort-AV: E=Sophos;i="6.04,194,1695711600"; d="scan'208";a="1114692658" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 14 Jan 2024 06:39:26 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 839D72AC; Sun, 14 Jan 2024 16:39:25 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Daniel Thompson , Jingoo Han , Helge Deller , Dan Carpenter Subject: [PATCH v1 1/1] backlight: hx8357: Fix potential NULL pointer dereference Date: Sun, 14 Jan 2024 16:39:21 +0200 Message-ID: <20240114143921.550736-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 d7298376cf74..bf18337ff0c2 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.rc1.1.gbec44491f096