From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 CFAF23C5DB8 for ; Wed, 15 Jul 2026 08:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784102873; cv=none; b=E3YcMwm6mg1Iu2V2QeECAdnGEh8t95XyzLtJSXKEzl309Ks0qD/T0XTL/yaO618W4hvLLhlpwip92WSrcBZjeiTefr7kWlRGX/ZaDr7KAI7d2sD+KBIjmPbqrgP87S9HwQzwyBJOz9q6RQwWLNJB4gUnNbX/ZoCk9Ev0N9C4yeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784102873; c=relaxed/simple; bh=Pw6j39/mGuQVfHy5bFeWSsKM0mU8C68IcHYtfdldUg0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sweC5nwlDJ1Ko1rnEZStHG3j2sUwF1l/h1WjIenzcesHJGogxROCNGE1whr6s9uFJldZfdjQC5DIyvs/7fN/2QvpGcnsyxvY3Jt4ibW58MjrlsSmoSRK3YeCz0+kBCnT03wOL7dEQzLzyjXuxdNxpuRyQ6U7O3TAsieEN+ciKDs= 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=Ma0jEcyb; arc=none smtp.client-ip=209.85.210.171 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="Ma0jEcyb" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-848595b338cso6040870b3a.0 for ; Wed, 15 Jul 2026 01:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784102871; x=1784707671; 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:content-type; bh=wHnh3usvn1WTvDIeVgeKjEVDyBZJfczrk0jzjtv/mDE=; b=Ma0jEcybKMC93WTAthR3ZpK3CK9FXegEd0msjK6YbLsiLW8324uxwl65PnZpKDkjj5 Wy+CWcQdJZAKMROTG+ZQqNMj/kuaeaYCoFfASbEViVWWnhNuLygYq2l//yTJzLA+9Vy/ IMwTOMJovvMrlIGY+f/1XHl9u/1HCNtarbShmCkaBTl+2tvUKdQ5KtZIze/ZoM2C7xCI Ap33hNPUQji8kIHaFEpLRDcdlMaOST6VP5LzYD5Po088qzviIbPAKzaD1st0Div96+AU 7mF7XfsBgAiQpD0jxk5Sk/hb3iOCKAiHrsNkjcHOfOlrQmFA62oQCrNSXLXJ5I38TtcW ID1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784102871; x=1784707671; 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:content-type; bh=wHnh3usvn1WTvDIeVgeKjEVDyBZJfczrk0jzjtv/mDE=; b=MerB60jvhVDnzRkxzHHy+EEcDYIRPryfkE58f0H3q0SdDdHBI7fgxi4PxbPz3IT+1I zy9uEF96hX9kQt9EQuczlq/0nY2q4akGwsIVGPGfVQX1clCrso9dsxWHTSLHfgaWThZ9 5jMW0l5bin+1RuSKLw1uIga5Lw8cdEjEjn7OKzvqE3iWgCD7XxZctiMMgpNLGcLoagwD prmIiDvak8rncE98zVvlyNSPKmkbwUJ0olbAGY28Co70j8RbzYGkn88C++XyIKDmjhYg Dd3+Z+fNorUSXaYPiO15k5/ncBSOfjzkp5C44quG8noDR6m8Rxh7WTN0pbJn8B26DMlv HQgg== X-Forwarded-Encrypted: i=1; AHgh+RrTteL79CNZm73HRYfHVaHLcyrQY/bPZvGm/Kq349WqX/gM6KPloby2a43aFpaOJfYbw9b3PcEbW7ZzXcc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy15tcRmOTCs9flFtPfsPAyXFJaV0v12meDz8zTBwxPBhaR/+aI t5bi+a98DZ0/Cflq7qd63/zgiyQvj3+UBt2Ia1WtThofaKGvYXzT2Y5u X-Gm-Gg: AfdE7ckqcOVJdCwUlFbkXZUtJSOPsJ0/4TsU44zuoYOReh19r7fN/ZWvasQfYUJ2g8U GEK7WKLyZBor3V+9YxVfk6smQiumbNIT7yu5cr/3/NeyQVnR40DnuvIexs0zDqP+3m4Gd/JitHT LD1GVcW0RSNRwlgUhblT275IFQ21i2FvscfvDhBMzaC8kE/QXh8IXXjsUVAVDNeQ9iHAn4RC0b6 IdvJLvCJSUpL1Aca/0sv61mTBotHS4shKp9gGADf3gU09gRqBM958cijqjteg3qAzVJmoJSuqa5 s6SiBUvp2Ee8lATJmglawr+3A+FLFbkUhTWw+91ml4bRDTTMmsZq/pF62SX4pGVUsnf+/DJYnDQ 87b1jiNxvWvtFGejimD5n01qVZ/J4F/hxjZ5byhZl1l41yhoYMt2jDH1v12J+R05pty2tsJ45d8 474aNIZdFhZv0/JPkZ3WpjqGAhipQXKUQ91pnwO3Wyv41FN+NVbaam5266QAo= X-Received: by 2002:a05:6a20:918a:b0:3c0:9c18:d5ac with SMTP id adf61e73a8af0-3c3572a7b78mr6354153637.73.1784102870893; Wed, 15 Jul 2026 01:07:50 -0700 (PDT) Received: from cosmo-ubuntu-2404.. (61-220-246-151.hinet-ip.hinet.net. [61.220.246.151]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ca79ac0e269sm9151431a12.3.2026.07.15.01.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 01:07:50 -0700 (PDT) From: Cosmo Chou To: lee@kernel.org, pavel@kernel.org, riku.voipio@iki.fi Cc: linusw@kernel.org, brgl@kernel.org, linux-leds@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, cosmo.chou@quantatw.com, Cosmo Chou Subject: [PATCH] leds: pca9532: Fix phantom device registration on missing hardware Date: Wed, 15 Jul 2026 16:07:47 +0800 Message-ID: <20260715080747.1638097-1-chou.cosmo@gmail.com> X-Mailer: git-send-email 2.43.0 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 initial PWM and PSC register writes in pca9532_configure() do not check the return values of i2c_smbus_write_byte_data(). If the I2C device is physically absent from the bus, the write fails with -ENXIO. However, the driver ignores this error and allows probe() to complete successfully. This results in the registration of phantom LED class devices and gpiochips backed by non-existent hardware. Subsequent GPIO reads from these phantom chips return bogus values (due to -ENXIO being truncated to an unsigned char in pca9532_gpio_get_value()), silently corrupting hardware state tracking in userspace. Propagate the I2C write failures back to probe() so the driver core can gracefully abort binding and release devres-managed resources. Fixes: e14fa82439d3 ("leds: Add pca9532 led driver") Signed-off-by: Cosmo Chou --- drivers/leds/leds-pca9532.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c index f3bf59495b68..9606c5b294ed 100644 --- a/drivers/leds/leds-pca9532.c +++ b/drivers/leds/leds-pca9532.c @@ -397,10 +397,14 @@ static int pca9532_configure(struct i2c_client *client, for (i = 0; i < 2; i++) { data->pwm[i] = pdata->pwm[i]; data->psc[i] = pdata->psc[i]; - i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(maxleds, i), - data->pwm[i]); - i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(maxleds, i), - data->psc[i]); + err = i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(maxleds, i), + data->pwm[i]); + if (err < 0) + return err; + err = i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(maxleds, i), + data->psc[i]); + if (err < 0) + return err; } data->hw_blink = true; -- 2.43.0