From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.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 6BEEA256C84 for ; Mon, 16 Feb 2026 00:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771203220; cv=none; b=NLSfAQB+oUiJk1f7P6Q+A20K1Ez04VUK5p0goDFzciqXCwczFJ0Mmj3P7nwRxu5gG7jpipvBr7d4cmkzvS2LajN4uyYOqXs6AYbTzh6OmiTwFaSA+hqleAKIHbrfRqDKRiQXWKtwDJD5NegX5QV3wxgnqDqs4m7PF3jkJeGVArE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771203220; c=relaxed/simple; bh=60hN41ih3iOsAB6ymTysRnh2xYyZO8I9uzHpwFHZRtQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WUoHBMCozlt+uP6C+iyrbkNs9uAG7MaFhLjaoPmouNrHId2qwpSBc/kH2dkjCIo98J45U3Qox2nkimCQak0pDbC5bOn3FjiFidbvFRUqD0ojHUImixZQpEtyjRfRRyixzqAtStyWTeeJvz6U2D+1zujaGwwZe+HKqgyVYDjMspE= 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=SsaBWMP8; arc=none smtp.client-ip=209.85.128.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="SsaBWMP8" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-7946a1f2430so21157697b3.1 for ; Sun, 15 Feb 2026 16:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771203218; x=1771808018; 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=vXcdPR7MA83++rX9pDUuu51PyGAjXa4lMqkkaZ3K5L4=; b=SsaBWMP8l6UOFllBy/vn+6aqDdqS+o14Vp2/soOKl20pBH/gCpU+5DeM5i3YJuHWB0 v0DVBSMGlFQYZwDTvdGabDwYz3Zy5qGcerhyxtrnVnKncDFZgJKLIGmBVvzKqgwtQ97i g+JRf0fCUHgMqeOEQ/ST/HCjtIJ2uZZO38GWTwx9ldEByhhqrxAmlGC/XrNxDBERyv2J cnK0B4X+l1qFyDLd5UzZdCPbaJJAKnejQ9mVBhdMZfgULZnPM50C83gOHhFbrnW6jTss DQX5G0SSxRVdxoJZk2JkOjXhHKVGNnMlCunFClRwIKmduCxsG+TM7Y+AyXvCmcX0WU0e 2faA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771203218; x=1771808018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vXcdPR7MA83++rX9pDUuu51PyGAjXa4lMqkkaZ3K5L4=; b=OHMnTyjZ3V+Vs/KvbXB4xSHMmDPEe4ibeFppw1CMKydRcoVWqAaNEow7UViPFPHNmE Zzk1QyiYO0Xsv/liHjOeDR6vV2lZj2eVMdBhcL4eWZ9pzZIjPcJcOTtNm0sFHJ5k9zxk KS/KV5AoN5lk/MeJeqLDo9StD2RcwepKX6VUdYyuRcfGd9sBrIRgwoSIDECnLia5U0IS R9QFmFaxV2W0rJ4q15OQPcBdzzuQwa0zFqtj8Iw0YkhDTTosT4b8RFWHW/M4NtlP6cRy vWJp19/sjWpKi3Vcq0M1XY+mgUlbs6IMgkWozff0hIt+Bt6cfEfS3ikKB98AP3wOxTeZ iUOg== X-Forwarded-Encrypted: i=1; AJvYcCVfZTPNa6zCmFeNVeE2QSlLGZZRkd1e/oJ5JK/HYFq4U8dLGg+jj+b//VHzRuF1crS3pZ+IfKXnSlbbEUE=@vger.kernel.org X-Gm-Message-State: AOJu0YzE6wcW7gP5EuXXd7Oplx2AccUqJOkvZ9ar63+FAMRk+Bgzx/Eu JWw/yHPyWLDEwRmQcnA5kTwIDBTexSJ2f2lpBa3YIAZ/fAIJbEB3Z2cl X-Gm-Gg: AZuq6aKV/t4URSkSUovOmzQdOSuoRKOnd3ObkcP546Ojh0yoK/dE2zqLeD44geiJ7uA FoY90jU0YzMr9H0b6dKCbNRP5rhec5ge5AitbnlXRiov7KjJcZTZ6lHl5474GEVNjW/I1b3JSyC Il2C8HG7Zgg0lqGtTaOJLvtDGdITzTF8wBkHlI0U461UHM2cyuWGXBbLbr1ngQnRgUtz6zem1zk yHASlBVv5zqUmfHe1rLZjHCRtwZnpPKWZKGm1xfo5m4IVK8CZC2SwGQJNk5UipHuj/G9+6Q4xuk hjwekiGn6wfwUkJBmCuY+IMeutY9RD67ozOL0yWQUuovGRu7fVMfOpnmilCK04hZYdd5f7HB+3P 99HW7vQ5eBoSwF3fJwN87Cv6pVVi2UZbCbctsbOrBQ4FJTEaGYWz1r1v/L/17Bfr4kKI1xoLY3T ZGbWfvnKeom/g3KJAQctxoM6fmcTF5aeUNj1ShUP5C0rrfLZ6FeGqDJAYg90ex2+8cp752YvIy8 bQ0bw/6CeS8GsT6eTtBdvPWazzPrB/RvyUAuQfCe+E= X-Received: by 2002:a05:690c:d96:b0:795:294c:fd31 with SMTP id 00721157ae682-797ac5d3737mr46326717b3.38.1771203218448; Sun, 15 Feb 2026 16:53:38 -0800 (PST) Received: from tux ([2601:7c0:c37c:4c00:e3a8:26f7:7e08:88e1]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7966c257ed5sm94797637b3.45.2026.02.15.16.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Feb 2026 16:53:38 -0800 (PST) From: Ethan Tidmore To: jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ethan Tidmore Subject: [PATCH v3 2/2] iio: light: gp2ap020a00f: correct return type to int Date: Sun, 15 Feb 2026 18:53:17 -0600 Message-ID: <20260216005317.11763-3-ethantidmore06@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260216005317.11763-1-ethantidmore06@gmail.com> References: <20260216005317.11763-1-ethantidmore06@gmail.com> 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 function gp2ap020a00f_get_thresh_reg() can return -EINVAL in its error path. Yet, the function has return type of u8. Added error checking for gp2ap020a00f_get_thresh_reg() return value. Detected by Smatch: drivers/iio/light/gp2ap020a00f.c:1013 gp2ap020a00f_get_thresh_reg() warn: signedness bug returning '(-22)' Signed-off-by: Ethan Tidmore --- v3: - Remove Fixes: tag. - Added Smatch warning. v2: - Fixed gp2ap020a00f_get_thresh_reg() parameter alignment. - Removed unneeded whitespace between assignment and check. drivers/iio/light/gp2ap020a00f.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index d1a511ac7690..fae7605f2f5c 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -993,8 +993,8 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data) return IRQ_HANDLED; } -static u8 gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, - enum iio_event_direction event_dir) +static int gp2ap020a00f_get_thresh_reg(const struct iio_chan_spec *chan, + enum iio_event_direction event_dir) { switch (chan->type) { case IIO_PROXIMITY: @@ -1024,11 +1024,14 @@ static int gp2ap020a00f_write_event_val(struct iio_dev *indio_dev, struct gp2ap020a00f_data *data = iio_priv(indio_dev); bool event_en = false; u8 thresh_val_id; - u8 thresh_reg_l; + int thresh_reg_l; guard(mutex)(&data->lock); thresh_reg_l = gp2ap020a00f_get_thresh_reg(chan, dir); + if (thresh_reg_l < 0) + return thresh_reg_l; + thresh_val_id = GP2AP020A00F_THRESH_VAL_ID(thresh_reg_l); if (thresh_val_id > GP2AP020A00F_THRESH_PH) @@ -1071,11 +1074,13 @@ static int gp2ap020a00f_read_event_val(struct iio_dev *indio_dev, int *val, int *val2) { struct gp2ap020a00f_data *data = iio_priv(indio_dev); - u8 thresh_reg_l; + int thresh_reg_l; guard(mutex)(&data->lock); thresh_reg_l = gp2ap020a00f_get_thresh_reg(chan, dir); + if (thresh_reg_l < 0) + return thresh_reg_l; if (thresh_reg_l > GP2AP020A00F_PH_L_REG) return -EINVAL; -- 2.53.0