From nobody Sun Feb 8 12:14:19 2026 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 BEDE621CFF6 for ; Fri, 26 Dec 2025 15:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766763937; cv=none; b=CEaaqb+J+W9B1VIN05NU+9vHbDZ8Z+ylzR/aEE3m7jJ9EPUcbOQ3rroJl3hJHIfgcm5KWWWkZJee1jYMEjLMTD8gXWJPFv3c24uuydxsrY5p+Y/otNf+RY4/F8opF5JwplxHpAslJb823B16pjN/DLn5UqFFbbKij1AVe3pglNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766763937; c=relaxed/simple; bh=92s0poAWhmByfF4NbQljHP/Pa+X879XWvw5HSZCXnTI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mMo+e616CvOzr58DlE8WuO9W/GV9VJm1TczhEz0Z1c6ihI+x+pII9tc9hGzpl5WHPdrpX/ndwfQUvLrKTdt8VskjX+2aBz/dKYtglyFL/zA8BpkKOHo1bB60cRuFPkNk5Ae90TN2LjewdNdkUwaeNLyMj18PfzILfhd15p2XG1U= 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=Cy4jMNg4; arc=none smtp.client-ip=209.85.167.52 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="Cy4jMNg4" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5957c929a5eso10552171e87.1 for ; Fri, 26 Dec 2025 07:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766763934; x=1767368734; 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=eCuFh5XNCOf6TK0qsZOzU7NRLpcavEMRDgLiYccbL/0=; b=Cy4jMNg4KC4E+1p2BkYsFvNJB3+yD//Guqkwk71Fe1Tzk+d8kh6mk74EPPJZcttxYZ j/JNHRU1LJvm8H5ebobN2QWpOFv4EhXIRcHkaUN1WtEDY6HM8rjFnIjqaTaHbq9axICJ gNIo81Oa8sgkgL61Jr1ibNd+Ejtqv2flvHet9xgNVC/4EsRnTw1wHBZ7n6K7CVjTsU0z 1oQvCm5S2f8ROvnEV1RVWzFm9Gabo2bB7uuDKoHfe5LAjEnlDBOvGfU1kWeiP3jUJNwc KdEoDAKOKIID7YgdbzNXLiqAyS0JMgHwrypS74UH7wLpPTs860akFWj33dXOrrQcJ8/S WpOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766763934; x=1767368734; 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=eCuFh5XNCOf6TK0qsZOzU7NRLpcavEMRDgLiYccbL/0=; b=LZd2uB8gyWgPCczHpcQ6Uu681LfICKxjGf2vSIRXUui8O38fcVYpBNsCtu9RBn1f2e W1wpSM0I2KrQPAmNQRLB4D2Jh5DAuKgQZBAHKvvb2tK97WXWkQMvrVdveUTJAHGZONfs +BRBnvOJ8lI4tu1NbbR4nGO1Bo5KnyPeA2Q4Kh8ODQBWYDaQtoz9QH04FnDLCxBGGjNl dlf4QDZzJx9SEn03/z+rK1t3bLl6IPdssPPTAlG5ZjP+PRirjKERe+9IOGb9/FigDBSY LOPV9SiggUMoz4Whn0rp0aaT8zdLocEHNth+xswVU1Yk9CAXgsjsuCqOIxXMmLbgQrOw B/ig== X-Forwarded-Encrypted: i=1; AJvYcCU1Bq76zzKL5hmthEmaXxAUdA+lthzhEQx/Dnsp9I5X31TLwcxK0pbTJqi0ZqW9esQjrWOLIv7cZ811QUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyeUzurmrd48ylAX3nLCat+fM9qSFlKVKdaiPY3ul78TD5Q4/VC kUy7WksEVWzPV0xYNWCQfe73yMI6T/aaAmcl2JpcIu3YH0P/4DjyRPkP X-Gm-Gg: AY/fxX7dW/UqkDd6n6CtLMT2x6Q5eDt0hkJCz9PRISA610wk0l4ZAppGRvTBSAdV1J6 +XhaUFBjuaXZN95nJSKeS5dL0800Ex+ijTgpBMyN/7a1y/dgKK27zvuy8ZUppdBnL3Viqk6pyxP BGrxikczfFMnsPuxNnBcr5EsoabDtkMZjzgyqguHAcClxpKamSz373ZHkMxm7K5gNOJk/HJs/nl 2C9IPoOgmaV2eoRErlaP3oLIFg4py6dWww4AzD+NHhEJzxxjOndnJEj5ye9NoDCucuI50f3KQpU HUKTefZkLpPG/B6RTzWVbnZQZLCZXNGistSol5m4RqLDHtenjin6YuKeXfR5/DZcjOKHsgITGRt Fdz36zL+iGDzlmefzWiESnFxumwl0AeOjK5nOCRppImP8js1n3eAJdQzfIuCOYlY+WeclWRStWv 95ibut+aLKvY+6MzcaSVj5UANZcpE= X-Google-Smtp-Source: AGHT+IFJFt9lbtBZuOum2RmOHfZaMwSl9YZ98mzh/mswdFGY3IXr1/OrvP66pMdGRoye90GXXKtobw== X-Received: by 2002:a05:6512:39ce:b0:597:d765:19f9 with SMTP id 2adb3069b0e04-59a17d057c9mr7534006e87.4.1766763933510; Fri, 26 Dec 2025 07:45:33 -0800 (PST) Received: from localhost.localdomain ([176.33.65.121]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59a185dd1e9sm6634506e87.23.2025.12.26.07.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Dec 2025 07:45:32 -0800 (PST) From: Alper Ak To: jic23@kernel.org Cc: Alper Ak , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: light: gp2ap020a00f: Fix signedness bug in gp2ap020a00f_get_thresh_reg() Date: Fri, 26 Dec 2025 18:45:21 +0300 Message-ID: <20251226154523.89215-1-alperyasinak1@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: quoted-printable Content-Type: text/plain; charset="utf-8" gp2ap020a00f_get_thresh_reg() returns -EINVAL on error, but it was declared as a u8. Change the return type to int and update callers to use int type for the return value and properly check for negative error codes. Fixes: 5d6a25bad035 ("iio:gp2ap020a00f: Switch to new event config interfac= e") Signed-off-by: Alper Ak --- drivers/iio/light/gp2ap020a00f.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a= 00f.c index c7df4b258e2c..9f2441fe8c52 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -992,7 +992,7 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq= , void *data) return IRQ_HANDLED; } =20 -static u8 gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, +static int gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, enum iio_event_direction event_dir) { switch (chan->type) { @@ -1023,12 +1023,18 @@ static int gp2ap020a00f_write_event_val(struct iio_= dev *indio_dev, struct gp2ap020a00f_data *data =3D iio_priv(indio_dev); bool event_en =3D false; u8 thresh_val_id; - u8 thresh_reg_l; + int thresh_reg_l; int err =3D 0; =20 mutex_lock(&data->lock); =20 thresh_reg_l =3D gp2ap020a00f_get_thresh_reg(chan, dir); + + if (thresh_reg_l < 0) { + err =3D thresh_reg_l; + goto error_unlock; + } + thresh_val_id =3D GP2AP020A00F_THRESH_VAL_ID(thresh_reg_l); =20 if (thresh_val_id > GP2AP020A00F_THRESH_PH) { @@ -1080,15 +1086,15 @@ static int gp2ap020a00f_read_event_val(struct iio_d= ev *indio_dev, int *val, int *val2) { struct gp2ap020a00f_data *data =3D iio_priv(indio_dev); - u8 thresh_reg_l; + int thresh_reg_l; int err =3D IIO_VAL_INT; =20 mutex_lock(&data->lock); =20 thresh_reg_l =3D gp2ap020a00f_get_thresh_reg(chan, dir); =20 - if (thresh_reg_l > GP2AP020A00F_PH_L_REG) { - err =3D -EINVAL; + if (thresh_reg_l < 0) { + err =3D thresh_reg_l; goto error_unlock; } =20 --=20 2.43.0