From nobody Sun Feb 8 17:22:03 2026 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 685033A1E94 for ; Thu, 8 Jan 2026 10:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767868647; cv=none; b=CUgmQS94hGpiAKU9ZQOIaOosBpdnLA41cpDBUmDBld8lLOiy2Rp4mBRUOt0Hz1n6kWDnhVcZHjG+8larxy0bhShaZaVurMV1/HNzNXlTkrF2NWcLXDbRlCrWWVdw9O+xYJOZraP7R1zpCCchj8i7wjt20nQEzEHsb2aVRoPhblM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767868647; c=relaxed/simple; bh=sGvjIE/LBJsZCF6hs86rR1o0wLSVIq1WUp0bGORn2Js=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=d2xmKmX7eeHvPHy1hwdKMgq7dTRwUHrxbLzMgPszek4N3imFS1BeVlesHF5s1tfEMhw+seCY5YxFYocr3hu7U+85cNwXZnoDXCbejIcaxMP67026rK3udDgiiHeotadLAjptazPbQ3QDXRNX6Zqa/yS2vSJQ3rU88zTASGD52DI= 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=aZsfUtkH; arc=none smtp.client-ip=209.85.216.44 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="aZsfUtkH" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-34ab8e0df53so2569149a91.3 for ; Thu, 08 Jan 2026 02:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767868635; x=1768473435; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1U5zRO+SPCwAl2mrA9Yp8CsA/asNYhp8z8hd3Fhm+uM=; b=aZsfUtkHFwf2wsi7IIEE0OHxpmuJbuuMjJoLuqBL2WCM0Qwp1uSD+oKsYbdR5SWtg5 O8ZrqE7lNBtWJsiRXimG1zpXkB2i4K9PVrrAUSdI/GzzUDB7PNzYktRU/vM7+HjgLqaG 8gBRz8TNV0fr8TzMg/jTNdW1nz4rum4cDkmpDR50KES0uqSPFopHeITRNsAKmEjUMXSx V7FMNA79xeGpWsYQD+qC//wfiPEOsn29eR8Hrda85JyY/oPDWeXDT0vhruzc/eDLNGno bXoUd23Pw40CxLZ+EeIWumFsJ8xIV+GGykwQWRgWvvLdYzpLiStuVOG7ZVeexNeL2Pi2 9jRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767868635; x=1768473435; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1U5zRO+SPCwAl2mrA9Yp8CsA/asNYhp8z8hd3Fhm+uM=; b=QrzGjbd9BYDawCRRLZgXeTd9pk/IknrK9rFeNuM3c3vfcfyDAzQ1ixizpveuDf8rEe YN0thJOJr00XXu3EaAC5Cf8MmcCSGgpERBB5mb4S+lDh4heractNeLM0mBxpngvygVzR u/JMjumnJ2GDb5A6c3/q2aTqnVPXOdbJQSBrI3mII4bNOKThWBt/L2vpmZlLZjjzQmPg ZcLVv2T37/Z5lrw0jpdcCXZ90mmOacFInU7zpAQ2RpemOxZXdI7gneWjmzsEuXjNvdDz XogayMLkPNQwToFwvdoGF8Q1LLrdh0MvGMJVdZ+2ET8zni5qWkjk4/nGn5x5nolv4Z3W XbuA== X-Forwarded-Encrypted: i=1; AJvYcCW3VUUiIt7dzjKiw8WEfQCLoHRHzv1+IFXXMCFlKwUeS2eKUaqUlrUVVW9AETEBnB6ep68p8viA+RbUB2w=@vger.kernel.org X-Gm-Message-State: AOJu0YyF/5g0igzVxJCH96FQkxayREKtxiFrczz3liWsM/1pKyc/xjOw jE06zCPNkelJFIERGPOz1FIkvlqV4SLO6wIGf8y7XKSaCBbgIOivTxKQ X-Gm-Gg: AY/fxX64K9zNNa6bvx8HQhBChzxg0X1BCAFIKJp3pOhbOadszpUBqIs2lwh7PnPnkro pqXSo9pI662OunRIbN5+pxo3aXx6IupnC1bqNf7eACfGvFZejM4ak2kb+4I9fMsNaPoDejsbBjN zN6HgkmkrIZgKo4psXCKjEkRrcR3ItMVYEmCJpPpNQtDdnuM5P5zgzdD9IQE8yV0sSNqmDhcwNd vjFAGb84yzumYKqleEH/Aghzxc4i2tCqicKIGsH3Q7VEYvJ8PUN8O2a886Pio7aBYBygwkx4H8B PcmVjBOitDkFGPvtxGQ22auNLwsoLxLpCw4YWnPtrLqn8cQHjRB07LMioiCVXROmS7YGTVBUMEQ ejWQEc4TOTcvyFW5W+x+Ry37pxJwq8ivhmKsD2bt2ZMcjrSyndtiOXk1Ppxu/pvlysjIskGHrpa HMFMX6VhaIyc5XRuDtzRmL3v05oyHfn1QO3JIn6BfCjjSNQor9f09QyM02wuU= X-Google-Smtp-Source: AGHT+IENIC3sjHqbdW2Eie4AgrjdVb6lo91WKNEjcp3xXk4I2aUvrWqa1grnwsWHVXwR65QMhFLxZg== X-Received: by 2002:a17:90b:1c87:b0:34c:9cf7:60ab with SMTP id 98e67ed59e1d1-34f68c62b63mr4446553a91.32.1767868635449; Thu, 08 Jan 2026 02:37:15 -0800 (PST) Received: from localhost.localdomain ([2409:40e3:44:c9c0:8d34:cc3d:a8c9:1a48]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cc8dd2sm74838715ad.82.2026.01.08.02.37.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 Jan 2026 02:37:15 -0800 (PST) From: Chaitanya Mishra To: rmfrfs@gmail.com, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org Cc: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, chaitanyamishra.ai@gmail.com Subject: [PATCH] staging: greybus: lights: avoid NULL deref Date: Thu, 8 Jan 2026 16:07:00 +0530 Message-ID: <20260108103700.15384-1-chaitanyamishra.ai@gmail.com> X-Mailer: git-send-email 2.50.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 Content-Type: text/plain; charset="utf-8" gb_lights_light_config() stores channel_count before allocating the channels array. If kcalloc() fails, gb_lights_release() iterates the non-zero count and dereferences light->channels, which is NULL. Allocate channels first and only then publish channels_count so the cleanup path can't walk a NULL pointer. Fixes: 2870b52bae4c ("greybus: lights: add lights implementation") Signed-off-by: Chaitanya Mishra --- drivers/staging/greybus/light.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/ligh= t.c index e509fdc715db..4c9ad9ea8827 100644 --- a/drivers/staging/greybus/light.c +++ b/drivers/staging/greybus/light.c @@ -1008,14 +1008,14 @@ static int gb_lights_light_config(struct gb_lights = *glights, u8 id) if (!strlen(conf.name)) return -EINVAL; =20 - light->channels_count =3D conf.channel_count; light->name =3D kstrndup(conf.name, NAMES_MAX, GFP_KERNEL); if (!light->name) return -ENOMEM; - light->channels =3D kcalloc(light->channels_count, + light->channels =3D kcalloc(conf.channel_count, sizeof(struct gb_channel), GFP_KERNEL); if (!light->channels) return -ENOMEM; + light->channels_count =3D conf.channel_count; =20 /* First we collect all the configurations for all channels */ for (i =3D 0; i < light->channels_count; i++) { --=20 2.50.1 (Apple Git-155)