From nobody Wed Dec 17 08:55:58 2025 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 9380E41AAC for ; Wed, 11 Sep 2024 07:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726041285; cv=none; b=UmD9KJXdmA0i8qWKBeCpvd1ZTQD7Rkc3hnDJj/LVTqPD9eoVa7I2Mv0OnqlQQ5vH1AAmWDhvkFJsJftiStUaKLQLyxjk59WC8so8+Iw5DYw+4FGa/AnWiIGxjm9XCmazw6TgJ1HLAOykwz1ZIT8z0/ZBVKhCwxxBhPTv686ylAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726041285; c=relaxed/simple; bh=YlRgfgg94/S+YD+u7hs0fDpJ4YnH6iNeSjeUa4mMHH8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=lFnljVBsV32OPv5YBVgQBU5DQtiErFsjYlAx5fCUYotLi8CBIw+kVLRIQqEz4RFffLornbS2cIhjWIYCPRivvCmzqRcRUQ5Os9ySUIOQhs7Y4zijJjGVvrV2xrfss3wszXx/JKqCNwMHi+brCq88BS01L7Ll4cq5kdtcCspaI/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WwLG9qF0; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WwLG9qF0" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42cb5b3c57eso31914625e9.2 for ; Wed, 11 Sep 2024 00:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726041282; x=1726646082; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WqbhBzP+AwPfpycxn8GsxBvEG+G4YMSO9DnKKL5O6Bs=; b=WwLG9qF0Aq7BVYaaCb51/BC3JOkVnHb3uZ7/2y+CrSsqOP5SZY+VT1eXIIZEA/Wynt owZGFlHQgXFNwhOMNDkt+/NXDnpKNKzO3iIc2jkf/tCNKjDAWqKxBUBOHaD235V7k4M6 1TFiwRPAow46IcidSt/Vx3mO7Sjn6YicWILCL79d7d6WwoE0Bo8mHDrLcWCQ3BFdouuD KMgf1HUV6oklntiMdY295n0jB9GYDRq1y8klVtzj1xXnZz6PQalmDMTKGHjdZAdNj5U/ 9Xo0e1MEvIfQWEo+wG9Tf1JUhyKVXRU4Rd3xHPqmr19gtTqzgwIEmL2Y3P3FOltawXcE ZmRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726041282; x=1726646082; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WqbhBzP+AwPfpycxn8GsxBvEG+G4YMSO9DnKKL5O6Bs=; b=vtXGlR9QaOKYT+oYDX8XZN1rgo/MiG8dFl/qqBpm0YKk+cDGeBl+qnKvrdAgx/rIjs 9ef1UimmXCMf8XjAw+UwmanvrpjQOcMG4d4KSZOH3/NRCPhCxrZSy33j3n8YxEqxRblk ssQSsqkIp/fTYBRMcyakfT+41CcDGB338LFbH53xc9qs7o/jIoSTHlSpwb/SIqp6exph bw/KaVxi/LhQqkEGwunDf3AGi2ZLZb3A+d3yy+d2bVSUUOoZTf5LGKdmJP/cfbKKFEoX q7XfISv7M+j6lDFvzgtn//+61KuN5SByYv8hz/L9ejhnX0lRiemg/OQOLycBVGZBuKpk 5qwQ== X-Forwarded-Encrypted: i=1; AJvYcCVu9NYMxpkOLNQfemv2W1+oGzycz9KV89YuUjLBOSoEd+HlURNZw9dnoDyjkhW/yxFJcPqhkrZxrd0GANw=@vger.kernel.org X-Gm-Message-State: AOJu0YwFjlbq8qcyvOZL2aSViI1nV7UbdZW/JfVHDx8nvEWojI9gfw8e tCGgQ5v8dVWxRSrXC/jc+XxY7CNsxJh0r4oVHHP3ti8ef0MNqxBhobjwPnKlnU7JZxYnD+23I1b p X-Google-Smtp-Source: AGHT+IF+JIETRuZS3KaW654cPaCnNTiUYodx1+48B9ArQWBZPpTcHlQbCGI9kxNJpQdkWvbN6vVhnQ== X-Received: by 2002:a05:600c:4f4e:b0:42c:b4f5:47a9 with SMTP id 5b1f17b1804b1-42cb4f54c54mr89048395e9.14.1726041281915; Wed, 11 Sep 2024 00:54:41 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42caeb21d3asm135033535e9.5.2024.09.11.00.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 00:54:41 -0700 (PDT) Date: Wed, 11 Sep 2024 10:54:37 +0300 From: Dan Carpenter To: Denis Benato Cc: Jagath Jog J , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] iio: bmi323: fix copy and paste bugs in suspend resume Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2efd1dd8-5a4f-4df0-8acf-972c91b7c9a0@stanley.mountain> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This code is using bmi323_reg_savestate[] and ->reg_settings[] instead of bmi323_ext_reg_savestate[] and ->ext_reg_settings[]. This was discovered by Smatch: drivers/iio/imu/bmi323/bmi323_core.c:2202 bmi323_core_runtime_suspend() error: buffer overflow 'bmi323_reg_savestate' 9 <=3D 11 Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on susp= end") Signed-off-by: Dan Carpenter --- From static analysis. Not tested. drivers/iio/imu/bmi323/bmi323_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/= bmi323_core.c index 671401ce80dc..d415b6542089 100644 --- a/drivers/iio/imu/bmi323/bmi323_core.c +++ b/drivers/iio/imu/bmi323/bmi323_core.c @@ -2199,12 +2199,12 @@ static int bmi323_core_runtime_suspend(struct devic= e *dev) } =20 for (unsigned int i =3D 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++)= { - ret =3D bmi323_read_ext_reg(data, bmi323_reg_savestate[i], - &savestate->reg_settings[i]); + ret =3D bmi323_read_ext_reg(data, bmi323_ext_reg_savestate[i], + &savestate->ext_reg_settings[i]); if (ret) { dev_err(data->dev, "Error reading bmi323 external reg 0x%x: %d\n", - bmi323_reg_savestate[i], ret); + bmi323_ext_reg_savestate[i], ret); return ret; } } @@ -2243,12 +2243,12 @@ static int bmi323_core_runtime_resume(struct device= *dev) } =20 for (unsigned int i =3D 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++)= { - ret =3D bmi323_write_ext_reg(data, bmi323_reg_savestate[i], - savestate->reg_settings[i]); + ret =3D bmi323_write_ext_reg(data, bmi323_ext_reg_savestate[i], + savestate->ext_reg_settings[i]); if (ret) { dev_err(data->dev, "Error writing bmi323 external reg 0x%x: %d\n", - bmi323_reg_savestate[i], ret); + bmi323_ext_reg_savestate[i], ret); return ret; } } --=20 2.45.2 From nobody Wed Dec 17 08:55:58 2025 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 4DC5133086 for ; Wed, 11 Sep 2024 07:54:58 +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=1726041299; cv=none; b=KdmnPmSVceu9Ilu4MAVSKoRqmgSiHtxUaQ2SohB93+Rsny3d+vN6Z88gLbdzP1d94NbXF7QHF8wcygbgK68/62yhD6Vzu515o0bABHcYwsY/OM8uj26VvzfIjSpkjXHXIF6ks997UvSd4qb7/xYfRjj+1/IWGPRItErVB0Qh3jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726041299; c=relaxed/simple; bh=FCNL3enQMB9b9oZ6WMqPum3crBISQcFGFq3X5va//7g=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=q8ikoyp3jdVdG1IWe1KZbU+8bIwOPlM28FC4bA1Ri8WioRrcT/RiuYQyEjAs9MiFZYcuNVUtGgAUtdvxtBydMCG7HpJhODjyvupBpQWnHBfiA1gjAVp9ujiuq59IjRrc9WXOexbctwxOwXQbDWLrk/G+4yNRcYmS20gHYp4J4SU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Jf7mYAfT; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Jf7mYAfT" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42cc8782869so11282105e9.2 for ; Wed, 11 Sep 2024 00:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726041297; x=1726646097; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=J6g1B5VNTS3oGUnmfFgas2SEgEdUHJ25qE4oeaeVF28=; b=Jf7mYAfTK+7+nLfpBRrzt0teLyOUOBMRtPJ/i1G7CgGswcZhh463d3hCCkYh5M567s p6GEiQUSDDt7Uo7ywZ6VogEQKaOA1vfDtuAYqBAs/qHXPveUcBkXipIzoqO50ZYwbxKP 4ox9vNR6RWmXfvM7p2xN7QferFy5wu0d03IrFWNdIWuf6wqdtewS4MXsN6hBdb606mS3 XByXBe99T7wxDTiconDnKE4JHTP/7PEPqCJ4PIrz+sU7R6+Gs0t7jSY9zqMA8CsY1/6L PwYGVg8RwY8dUp4aAwNTDROesiBEZXLzcdqDseEwFz/4HcoV4rblNAnfn8513YNYs0Rg 0Yig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726041297; x=1726646097; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J6g1B5VNTS3oGUnmfFgas2SEgEdUHJ25qE4oeaeVF28=; b=UZjKvMQdBOlklA1Baq64Q4GNROTHyc4JTZjxFCzsJA3rczwdQVs2NpmKUuhdZnqFl8 4HQqquwmQfCTfWd0duPIuBuGstvPAcWjm/jNGYY0rA/NVuzsqVs9QgtexCBYv6aD6OpF TEm3XthDNwrKMKiGlFCitC3KVjyrMD26BmBHyQFPhY1+mDHUHiBCW+SA+bRTnKXwQ3mE dv+4ytq0lP/3PunMvBdArkX2ScEIm9I1tP+2K704N44rNLDKUSahuhRcrstfwWKWISkO 7FAm0V2ROKZyG7M27/4Ljis7lPPqmTUNDiY5od09o/onkIkVydYngEx1G/1ts4Wo+spt Y0sA== X-Forwarded-Encrypted: i=1; AJvYcCUUh57rInKrrkInJmU5Jlsd+S1jLsQd68Wav7jPod94OQeLzZUoP9VXyBkeAaJ6RT3MzHuUV97oymrlhf4=@vger.kernel.org X-Gm-Message-State: AOJu0YzAc16jW5m99W8xQLjspJkQFurpEKzo/7mgPsfy+SCPF3msUkHq ZMQCuz2YnKTgGQzkLeV4LyT8/CyRYJLvOeVqAumvKd+xQgy64APAoC45FAw/UuA= X-Google-Smtp-Source: AGHT+IGMaGtd5pusGWK5gC/LDrjf44vrtvtmz1nIDEiCzD9gkk+z8vd9V1M7P304PtExRrT4QkP1sw== X-Received: by 2002:a05:600c:1906:b0:42c:bae0:f066 with SMTP id 5b1f17b1804b1-42ccd325863mr17424475e9.13.1726041296559; Wed, 11 Sep 2024 00:54:56 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cc137556esm42959305e9.1.2024.09.11.00.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 00:54:56 -0700 (PDT) Date: Wed, 11 Sep 2024 10:54:52 +0300 From: Dan Carpenter To: Denis Benato Cc: Jagath Jog J , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] iio: bmi323: fix reversed if statement in bmi323_core_runtime_resume() Message-ID: <273b8f96-0d32-4913-bc6b-e91b391e7d7c@stanley.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2efd1dd8-5a4f-4df0-8acf-972c91b7c9a0@stanley.mountain> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reversed if statement means that the function just returns success without writing to the registers. Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on susp= end") Signed-off-by: Dan Carpenter --- drivers/iio/imu/bmi323/bmi323_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/= bmi323_core.c index d415b6542089..a56259c6434e 100644 --- a/drivers/iio/imu/bmi323/bmi323_core.c +++ b/drivers/iio/imu/bmi323/bmi323_core.c @@ -2232,7 +2232,7 @@ static int bmi323_core_runtime_resume(struct device *= dev) * after being reset in the lower power state by runtime-pm. */ ret =3D bmi323_init(data); - if (!ret) + if (ret) return ret; =20 /* Register must be cleared before changing an active config */ --=20 2.45.2