From nobody Mon Feb 9 04:09:29 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D12230FC21 for ; Fri, 30 Jan 2026 09:24:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769765060; cv=none; b=Xs7lbGD6hNe5Dtzg0gwHdWl3X7nVEN7o2JEXthS9B0gP2bK6QNQr9R7x0mLeqzMu4ucVyj6CjBRoneaVFzCYJsStjpINH1LJ0APV556uBYhXEmDFmUJq+hBeUsltektyGlO48loLTxjWFOyxA5SQ9T4MU3D33h9j2vW0t8dZf2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769765060; c=relaxed/simple; bh=Z0lRpw++sfVMkatZsjVNQJK37NTBLAhxR2yW3jbslP8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=icnPQthUau4B0YsgrVJJJjg8F9/H4WxGsSGTmUZkp/prPdC0sxRKdLHSFOeNWtc0EU3DBXVhXtcqobyaBC7Uu/LrDS6ilEKmtNjTeHsW67HAexC7vvlPaNarL1UiTJU3fVxoeYyS0yvG/x0dw24jW2SF1ECSczW/u/NsgQwfUUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost (unknown [124.16.138.129]) by APP-01 (Coremail) with SMTP id qwCowADHM2+feHxpxCe7Bg--.232S2; Fri, 30 Jan 2026 17:23:44 +0800 (CST) From: Chen Ni To: lanzano.alex@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, lumag@kernel.org, mehdi.djait@bootlin.com, u.kleine-koenig@baylibre.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Chen Ni Subject: [PATCH] drm/sharp-memory: Fix IS_ERR() vs NULL check in sharp_memory_probe() Date: Fri, 30 Jan 2026 17:22:59 +0800 Message-Id: <20260130092300.3426214-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowADHM2+feHxpxCe7Bg--.232S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Wry7tw1kWr1Dur17XryUGFg_yoW8Aw43pF s7JFyjyrWDKrZ2kw4xta1kCF1fCw10gay8Gr929wsruwnruryFya4fG3ySvF1UJFW8A3W3 t3ZxZa15uFZrZaUanT9S1TB71UUUUUJqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBG14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1ln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE 6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVW8JVWxJwAm72 CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7 M4IIrI8v6xkF7I0E8cxan2IY04v7MxkF7I0En4kS14v26r1q6r43MxkIecxEwVAFwVW8uw CF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j 6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64 vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0x vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUw4SOUUUUU= X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" The devm_drm_dev_alloc() function returns an ERR_PTR encoded error pointer on failure, not NULL. devm_gpiod_get_optional() may return ERR_PTR in case of genuine GPIO acquisition errors, not just NULL which indicates the legitimate absence of an optional GPIO. Replace the NULL check after devm_drm_dev_alloc() with IS_ERR() and add a missing IS_ERR() check after devm_gpiod_get_optional(). On error, return the error code from the probe function to ensure proper failure handling rather than proceeding with invalid pointers. Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD") Signed-off-by: Chen Ni --- drivers/gpu/drm/tiny/sharp-memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sha= rp-memory.c index 64272cd0f6e2..5e6a54a0696c 100644 --- a/drivers/gpu/drm/tiny/sharp-memory.c +++ b/drivers/gpu/drm/tiny/sharp-memory.c @@ -541,8 +541,9 @@ static int sharp_memory_probe(struct spi_device *spi) =20 smd =3D devm_drm_dev_alloc(dev, &sharp_memory_drm_driver, struct sharp_memory_device, drm); - if (!smd) - return -ENOMEM; + if (IS_ERR(smd)) + return dev_err_probe(dev, PTR_ERR(smd), + "Failed to allocate drm device\n"); =20 spi_set_drvdata(spi, smd); =20 @@ -553,6 +554,9 @@ static int sharp_memory_probe(struct spi_device *spi) return dev_err_probe(dev, ret, "Failed to initialize drm config\n"); =20 smd->enable_gpio =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIG= H); + if (IS_ERR(smd->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(smd->enable_gpio), + "Failed to get gpio 'enable'\n"); if (!smd->enable_gpio) dev_warn(dev, "Enable gpio not defined\n"); =20 --=20 2.25.1