From patchwork Tue Apr 1 09:16:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Martin X-Patchwork-Id: 14034557 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 208481514F6; Tue, 1 Apr 2025 09:17:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743499024; cv=none; b=QRdRrgr0y1SoYRNgDXv271G/0iHvzSV0TwHXUH7uGpCXphjwHSezmgq0nc3lQgsPY3/qyWa60zIsKEpdpfuzv2d38Se0t+JqcV0NcrmFtFtZDhbnRlWHtjSHWbdkpxST50YwGpJ3cQqCQgXDQsRfclpY7KEiXIJFIRLkk+jzsbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743499024; c=relaxed/simple; bh=PXFATimqMqSBc1k8B3/5XU/qx7AM9Z/4Y86iX1AA+1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tAQ1fiNHHSQOPhSGTULVbYi4TnLYiEIKCOCZtwKVWFDzeeClY+aBUoHe4PI4JTuj7XjqFGkkZPKYPSzJmlvyQUXfvZlF7ke9OHnQKybWTZHe+uaViDfvVXHmZeYQUdzN0NXUlJolDI8Ipp6QdBNP28AW26M6m9v1XqHgpM/om6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V8ssTNxH; arc=none smtp.client-ip=209.85.214.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V8ssTNxH" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-224171d6826so76646745ad.3; Tue, 01 Apr 2025 02:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743499022; x=1744103822; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+GLEyWRUn87tdAHFpsIgdK3yHHnhiGzWNhKJ4cVG5iU=; b=V8ssTNxHEn76vu4tZaSLUrHsqwWXNFCZvo8Tx/5mFNizbL33LZXrc4DsyZfSmhPg+S c4uUb6A20tUJydDF/izyc8pthOrMxBqrumsvI/gYKYPuZMrbmnSyXrWikQsrcBq5G5nB ZKJL8bUouIBS9lY+BgEwSMqAKCSjYn+Af6yxX+hexKceZiF4CJRtu4qV+PU3NqMx5GOh PNrOozIniwX47uOjmpNz94ymZDGBHe6gW4K57ADsm6vP8/ETx0laYacZw1LKH0gvsj0k ccwwrn311sdJKX5PVV5Fc7S2dxWE+uDOzCBD/L3LMoREp5p5K1Fc+Ig+fFGU/Z1wauB+ 9XYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743499022; x=1744103822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+GLEyWRUn87tdAHFpsIgdK3yHHnhiGzWNhKJ4cVG5iU=; b=VWq71E88oVZS+xqYBpzosA0KpMI4FwD+JFl72KDljJCukHus8H5qznOL+YoZsRlZEo vPfAhQ5WfEqLPwBoBsgRRt93/Ox0OdfYHnLrrMmAjU1M8VVksiwcpvZiWXo2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AGHT+IHunF5jyUL3TmPXi3AK47epCDZ22lyUsYqq4UiVJYVJRr74B+C/7SC7nQxjxJzTz0Tx+kvJng== X-Received: by 2002:a17:903:1cb:b0:223:f928:4553 with SMTP id d9443c01a7336-2292f9f7646mr232149915ad.44.1743499022271; Tue, 01 Apr 2025 02:17:02 -0700 (PDT) Received: from henry.localdomain ([111.202.148.167]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291eedf9b4sm83492285ad.84.2025.04.01.02.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 02:17:01 -0700 (PDT) From: Henry Martin To: danielt@kernel.org Cc: lee@kernel.org, jingoohan1@gmail.com, deller@gmx.de, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Henry Martin , Dmitry Baryshkov Subject: [PATCH v4] backlight: pm8941: Add NULL check in wled_configure() Date: Tue, 1 Apr 2025 17:16:47 +0800 Message-Id: <20250401091647.22784-1-bsdhenrymartin@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 devm_kasprintf() returns NULL when memory allocation fails. Currently, wled_configure() does not check for this case, which results in a NULL pointer dereference. Add NULL check after devm_kasprintf() to prevent this issue. Fixes: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name") Signed-off-by: Henry Martin Reviewed-by: Dmitry Baryshkov Reviewed-by: Daniel Thompson (RISCstar) --- V3 -> V4: No functional changes, just correcting the version number V2 -> V3: Correct commit meessage and confirm this patch has considered resource cleanup to avoid any subsequent issues, ensuring that errors are handled properly and no resources are left in an inconsistent state. V1 -> V2: Fix commit message to use imperative mood and wrap lines to 75 characters. drivers/video/backlight/qcom-wled.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index 9afe701b2a1b..a63bb42c8f8b 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1406,9 +1406,11 @@ static int wled_configure(struct wled *wled) wled->ctrl_addr = be32_to_cpu(*prop_addr); rc = of_property_read_string(dev->of_node, "label", &wled->name); - if (rc) + if (rc) { wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node); - + if (!wled->name) + return -ENOMEM; + } switch (wled->version) { case 3: u32_opts = wled3_opts;