From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 0EA3C3A7F57 for ; Mon, 27 Apr 2026 21:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777327091; cv=none; b=k2lSxeqRwYjqu6uWcvfTJtiMdupoJYj7QD2cfQmokzugk8JTQuWBwI4l+f0E6i0nKgw1NtaAbjtn23cH607KVxyX9GVB6CRCZ+2jintm3vaz5J61KsB19QhJVvN+KNoSlmbP9MGdVqMi0PPEYbOp+GK+xnrCudYuNm/5PSAcLbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777327091; c=relaxed/simple; bh=4aY/45S6uu+ueqf0r3Tct1zhYR6DX6LmiB4UWgyy0Q4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EmNam4rV0z8BfhI26SK0JsvY/ONmhW8G6FU3GW51/euqiMD9BschaAsJCtHX2P1OzUk0247mvnWWtYS559TBT+hN/S2wVI1RCbYxOwhrTIAryQwIYumWqL1VcTY5LQN4dRd4UOq/uGTgzBztAPjXuSFYb5II4721/76Qsaofpbg= 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=SfdcndrJ; arc=none smtp.client-ip=209.85.128.47 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="SfdcndrJ" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-483487335c2so105417515e9.2 for ; Mon, 27 Apr 2026 14:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777327086; x=1777931886; 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=SGFEGVArNncRbb7nlEyVjRWdYLiwwjUBeFv4UPUGaDw=; b=SfdcndrJq1yx+1EvGa2k0PZuLdUU55gUP9bYC/rRCd1IW7+0LwuUw7p6DGy5j54mvt KAQnx+1bjsI47/LTwlhcsbWxWA+HXSEojFG1upbeP8zel3yfD8HDVbM0RrATD20fLSsN /60nOuAYHUSAcn0E9k9TG9or50dtRnvLsshp/Go0eHrsm9irORQJstPvUYhdqBpDjw8b 2CwV3eQsLqAmDtpU0O5SPoVl2qiwxEWrhIWRh/KQ3Ffr8KrpKiLDE+NgMhGY7G1ciI+I dzuUpixfgs3tez/NHPfsv9tAMz/aKB6rfbwF0pBwR4PhDySrGCLbd81gc/hxmSxBlcoi IGhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777327086; x=1777931886; 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=SGFEGVArNncRbb7nlEyVjRWdYLiwwjUBeFv4UPUGaDw=; b=OQvEbZIwii0q3xFji1BMUaRY/eUOpUTVGROwbpS89LJ2nnelO2oemitAHgKhcLk4Ri ticcim9ROx3GUcLWasrYsNkZ+ZHV1kGg09REvurwJDdpg8vImnl78BEAxvEqdwC7K/2/ sEpYAxLNHXV5wjCqcWz1e4YY75XmFU7pN8x+chdj9JXoB//elQzJGm4cfAbbNxft7Phf wjvYXUSvS8STtuRlPtHaZIBy8ZBkUnrFjKQx5C0grZuH1ofdrgCHVHDFVcCvI8evVG/Y tLF4uV9YnGELcWpVaAGzbTWMrma8YIFs2j4W7hZPbEfW0iDyZisUWX2+3fxbp1K/H20T GZaA== X-Forwarded-Encrypted: i=1; AFNElJ88W6f8WP8ks3AqaI6U1MWr5iOMZAfRgCWXF1qvH2fzU/d5YEVYcG/yKPqreqyUoymrlJo6pt219nseITo=@vger.kernel.org X-Gm-Message-State: AOJu0YyzphXSQrL5xEBPL6wGgb3Hxof/wR9cHQIYHQoky4WA9p6EQ+o0 K6wNfUsOzHsTkg6/NpknOqHthye7XtLydg2inhZ+w3muj+4L3p6JMTat X-Gm-Gg: AeBDietgphZyxvVV6uoJAEgB7IkKsAu3LRYnEE0kAjNrflbhNnKIL9sYMN904Hns2kS RS01k73hZSJxxrz7xHeIivyM17dg6XWX3zxXORSGex+7xk+sOX3vgfPtrLqq4qIStF+LUSnxCO6 K04/4NGtS7vqJMJJ6QtKqg+AYfRuXQaRTKm52wLoj2FGXcSYZj4RWkglJ/3NBfsMqgGkwmfHr6E BUD6yoFmGRkrlvCmPuLgitr0BLGpFmtZluMFqHL2QyKSNb56HMZ44vUqRU9Hpo/lm4UzosSXQ/9 hOgl47b2sFP1/PFz1YAP8Bx5MPdSnPLiaOQqDwSdWZTXX7JWK3cHIq7D1EZ6ehQ9DxKMHFu+Vu7 rN5K+gHd3DvABluSR6dOUtg6kbDo0m2XZJn2jx76MHc/RAJDgKghbYn1pf7i1aMXdBsMnoigJ0a tRDkSQ26znLONP4dF+V5mcqduKY5xC4I0ZSlyOEQZUDaZw3mvn X-Received: by 2002:a05:600c:8b2f:b0:48a:58ae:993b with SMTP id 5b1f17b1804b1-48a77b178b3mr6765775e9.16.1777327086287; Mon, 27 Apr 2026 14:58:06 -0700 (PDT) Received: from localhost.localdomain ([196.235.239.18]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a775eb912sm3854655e9.21.2026.04.27.14.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 14:58:04 -0700 (PDT) From: Salah Triki To: Crt Mori , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Salah Triki Subject: [PATCH] iio: mlx90614: fix missing GPIO direction return value checks Date: Mon, 27 Apr 2026 22:58:00 +0100 Message-ID: <20260427215800.28082-1-salah.triki@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 functions gpiod_direction_output() and gpiod_direction_input() can fail, but their return values were previously ignored. If an error occurs during the GPIO configuration, the function should abort the wake-up sequence and return the error code. More importantly, failing to check these values could lead to the I2C bus remaining locked if an error occurs after i2c_lock_bus() is called. Add return value checks and ensure the I2C bus is properly unlocked via a goto label in case of failure. Fixes: eb4b07dae4d4 ("iio: mlx90614: Add power management") Signed-off-by: Salah Triki --- drivers/iio/temperature/mlx90614.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index 1ad21b73e1b4..ce12b44c84e0 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -489,6 +489,7 @@ static int mlx90614_sleep(struct mlx90614_data *data) static int mlx90614_wakeup(struct mlx90614_data *data) { const struct mlx_chip_info *chip_info = data->chip_info; + int ret; if (!data->wakeup_gpio) { dev_dbg(&data->client->dev, "Wake-up disabled"); @@ -498,9 +499,17 @@ static int mlx90614_wakeup(struct mlx90614_data *data) dev_dbg(&data->client->dev, "Requesting wake-up"); i2c_lock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER); - gpiod_direction_output(data->wakeup_gpio, 0); + + ret = gpiod_direction_output(data->wakeup_gpio, 0); + if (ret) + goto out_unlock; + msleep(chip_info->wakeup_delay_ms); - gpiod_direction_input(data->wakeup_gpio); + + ret = gpiod_direction_input(data->wakeup_gpio); + if (ret) + goto out_unlock; + i2c_unlock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER); data->ready_timestamp = jiffies + @@ -515,6 +524,10 @@ static int mlx90614_wakeup(struct mlx90614_data *data) i2c_smbus_read_word_data(data->client, chip_info->op_eeprom_config1); return 0; + +out_unlock: + i2c_unlock_bus(data->client->adapter, I2C_LOCK_ROOT_ADAPTER); + return ret; } /* Return wake-up GPIO or NULL if sleep functionality should be disabled. */ -- 2.43.0