From patchwork Mon Sep 16 14:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13805536 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 68CB215B963 for ; Mon, 16 Sep 2024 14:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726495761; cv=none; b=Y2uOJoX9en8RWgqJBtxmC8PvHx1HBdSu0A2Vjzl7Bz4gP0r6tuHuDGJkv9mJtylIEEC3n+oAGNPhB0Yqtm64yV80j316LnuaUIUOM7VNj1QkEVeX5tY2zxcPo87303v6MbwMKIieUDfxU5/7sy4/LzU9POj3OSKbUsfTxFiPNfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726495761; c=relaxed/simple; bh=oIihtEvugRekngdvGX9njfL9N3T0RbQ10ngt0gMQo5M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XQxX8hc/8v1GVt9nj76mdPhsVdjPnRhxCN73VtjQRRVgFHlD2hDil6jN0Jfl8V1iei+6xOyJI4r8j1qHfySIGHGTcAgDpTo1U/067sQ5EfgtKyg3bY9CsaNe54MDcNPadBt+O6ypyu4TObWoA+4/Mxt9uNbCNo9FGQlawPeOxJM= 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=DUvsLUqg; arc=none smtp.client-ip=209.85.218.45 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="DUvsLUqg" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a8d6ac24a3bso824000466b.1 for ; Mon, 16 Sep 2024 07:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726495758; x=1727100558; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=96jeFUgbQRZST+IYwU8Ial8RWWjGSXkDlbIleOFp4OM=; b=DUvsLUqg9N9NDtNpHXrYuFqWLcTH6OHP/dVVTfu3rRTsauhgtd+/777gy939XfdJbg VR9nPxMNajliOMvPOoMmfQVUUPzv7xEyNFPosl+bx2GbkMm0Ay4Enia63rORUVuo3azC nfp5r4BTuimSg3WLM729z50n+FH6+LFUzayZSCmtk+HHvRtDCr1vASWAUNPvMyk+IQNF iXJ+cH2VoJGXB5Ti6e/fXw57mDbozzQTFVzaUi96/uGLkTlEmGfeNxZMihEEPi+BAuI1 e7+MI5aI11SmF+0gO0BTq5kn3wFNFfk0273a1mGwYa6l+Spu+sMzqzAGX6aG9SyA2Wxj j9+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726495758; x=1727100558; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=96jeFUgbQRZST+IYwU8Ial8RWWjGSXkDlbIleOFp4OM=; b=INOpbDWY2V3l1h9xRnWncmdXZQcLpvQ84fbOMpQCHENhKf/0sr9Wma2MjfMHBtSCiz k3B2ZSAJ4AfDWfdw1Do+jiT4KUtgdNLhTFFFj21DNzKB26TCYfbi/dxn39zrXvNocSzx Mm8YoGTEpyuoeYK3QQ3JPmk0k+/SskXvhjxk+ZezBv/6mVpvl1w++1gX4wLA68BDJCg1 9U3boZV5O7QZQj/6RhLHotR3+ifP2PvaXQ2Pd5m0kFdCLGTO8uop7P213QBtDWbxUePL NDteKHHeh7+h6XfIPqBVvmF8nBgfFtpBCZKqM9uyhCRqmuWWd+lPIPTcqHPWwJvHCRAH +8fQ== X-Forwarded-Encrypted: i=1; AJvYcCWl9l1QqwCEptWujx60YSQcj2kcXvOKYwI49yAg0e1hWDx+kKZxSJ/OaUavPfkG/XagaJ32hfchb8g=@vger.kernel.org X-Gm-Message-State: AOJu0YwrR/SmvKIaLUhI82r5hCPJwN0GA1Hnnc2Aqwgl424af519PUI7 RmWSsslYvG/zmIoKvAxyeHr+V29I+dBQVf0o/gve5pczMyUcO2t1zVuWA5U0Rw0= X-Google-Smtp-Source: AGHT+IHdZDPEBYWGYVLwV9TT2w6/zrnSjBTkWHdxrQG17ms6CikqS20u1qTFWfpLL/hEdMh16kOitg== X-Received: by 2002:a17:906:3395:b0:a90:34e8:6761 with SMTP id a640c23a62f3a-a9034e86912mr1253481866b.6.1726495756446; Mon, 16 Sep 2024 07:09:16 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90610f445fsm322270666b.68.2024.09.16.07.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2024 07:09:16 -0700 (PDT) Date: Mon, 16 Sep 2024 17:09:10 +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 v2 1/2] iio: bmi323: fix copy and paste bugs in suspend resume Message-ID: <7175b8ec-85cf-4fbf-a4e1-c4c43c3b665c@stanley.mountain> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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 <= 11 Fixes: 16531118ba63 ("iio: bmi323: peripheral in lowest power state on suspend") Signed-off-by: Dan Carpenter --- v2: no change 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 89eab40bcfdf..f6ff07ba98cd 100644 --- a/drivers/iio/imu/bmi323/bmi323_core.c +++ b/drivers/iio/imu/bmi323/bmi323_core.c @@ -2193,12 +2193,12 @@ static int bmi323_core_runtime_suspend(struct device *dev) } for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) { - ret = bmi323_read_ext_reg(data, bmi323_reg_savestate[i], - &savestate->reg_settings[i]); + ret = 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; } } @@ -2237,12 +2237,12 @@ static int bmi323_core_runtime_resume(struct device *dev) } for (unsigned int i = 0; i < ARRAY_SIZE(bmi323_ext_reg_savestate); i++) { - ret = bmi323_write_ext_reg(data, bmi323_reg_savestate[i], - savestate->reg_settings[i]); + ret = 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; } } From patchwork Mon Sep 16 14:09:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13805537 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 E5EB515E5CA for ; Mon, 16 Sep 2024 14:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726495765; cv=none; b=dhV/lrWBA6ybV6rFHmgHOE48qdtTE79n/9FKFVoHmQc7MseILnD4qXhI15WmAhkV56Dekmte0TBZ9hc13a88FqAad/58g95pzfGOwIoHzf6tvB+F4gOu7W8cdWjfRs+E2FE6vJBzC6jHsp11xoIxoeQH9+moVeXbO1X3mR4iwyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726495765; c=relaxed/simple; bh=NX5kItBI6qWChtIaNT2kylD3MQKq9w7BzjD6DZoxbDE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kwfP3MEIL3xhW4vfEULjXG3wWSv5eMm2v/d4vpT5taFBoVK5Kg/QV8p8Sak0FNSQxndPE3RbJxY+Z0CnOO69FefZwUjxudSMFDWLckEK0TKsJgRI6xGp0KTAX681OD3bCdiN95oi6grXwEcB/DsMS6rF9jNh8vEh5eiyEwjOQjg= 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=K7QZmDpG; arc=none smtp.client-ip=209.85.218.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="K7QZmDpG" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8d60e23b33so589916066b.0 for ; Mon, 16 Sep 2024 07:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726495762; x=1727100562; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZhWdIDXVnRhjARMzfOhbCyFUIgcuuqCXLNl4MzBeIg0=; b=K7QZmDpGgmVdiqSOXak4dnBieT/pxEi2ZAZxwaCUDbXxeN9InFgXzap3gkmkbB5ghB MHrjg2v3nP52uBgUxBl8cgi3UGUM2w71AeCj/lwnVap0PtKRYEaEzlM+N2ATlesCEl05 wpiRYCBErB8GXyRn4SNXWqlL8xXwztcYeqS9xWh6qDJZfSx4FJ07Ql+d6UrTWezHX+CX 3T4CLevock6cufZ2yH37wTarUHaGsLmN04Y3FRzhZ4VSSBQbt6kCP83BUr9yNMYJPrBA xvnDHdvBRItD9nHD0NSA9F6qSu+VfyhccVxSLrD5tapBSyhvCDMng5jz6BywLik/Jxj4 T1gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726495762; x=1727100562; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZhWdIDXVnRhjARMzfOhbCyFUIgcuuqCXLNl4MzBeIg0=; b=FdqV89q34yZ+P/6ypOMqqoZZAduxzhp1jUbPzUw8zVH4EyWwNPN9/urCP5gLGw73PS rhU2m4ouFkS9lIFbQR0z2UQtseEWIU/4RClwi8XTXRm6dDnhj8SP3yP6bwgZqBrjfyVD txywVnxm3xFch6xLRQpqZ4N8yN5Ys78la+bVY7NtWL1K3oFVnYhGSDh9V0Cgv13rIn5y 0O9wa+CHNXjl5jVqJUGmKJcsfXxbeFuhQ7ju5yu+YNv9UF3On0/167pQxMuUwatHPlx8 ke9/9QXlStwg+4Q4tq2z56K2Xudowpi/9EoM/0F5rlelWDdCuQ1G6mOon61TGILK69Cm 2GnA== X-Forwarded-Encrypted: i=1; AJvYcCUsMY42+8OoLy/tsioXmnK3bSV1XPQPo5D0ovh+kHdmf5WlrfFGkWOWHvhIELrMPqyjYDdvDBpp1Xo=@vger.kernel.org X-Gm-Message-State: AOJu0Ywhdekv5EhZY+dkkUjoIDn1nkVD8r4UAGVQbNosHCtDhVZf0HRB Enrx8i8GqZF2fA2cwuH1LQ9TT4NZYMfz+NmZvdkDz3/sr7tiLMdRpHyAUzxp63Ru/LmSJB5JReN 3 X-Google-Smtp-Source: AGHT+IEZzIM9A+aqMP7t3V0EP26ZH1dlD/AwzLiHQs10yeXD8zAfdCjeoGV4RvP6VJWRp8ORItjbaA== X-Received: by 2002:a17:907:72ca:b0:a8d:2d2e:90e6 with SMTP id a640c23a62f3a-a9029674fb4mr1717029766b.60.1726495762282; Mon, 16 Sep 2024 07:09:22 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9061096a29sm322687466b.41.2024.09.16.07.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2024 07:09:21 -0700 (PDT) Date: Mon, 16 Sep 2024 17:09:15 +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 v2 2/2] iio: bmi323: fix reversed if statement in bmi323_core_runtime_resume() Message-ID: <689a2122-6e2f-4b0c-9a1c-39a98621c6c1@stanley.mountain> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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 suspend") Signed-off-by: Dan Carpenter --- v2: Added the dev_err() message drivers/iio/imu/bmi323/bmi323_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c index f6ff07ba98cd..527d6c321ab3 100644 --- a/drivers/iio/imu/bmi323/bmi323_core.c +++ b/drivers/iio/imu/bmi323/bmi323_core.c @@ -2226,8 +2226,10 @@ static int bmi323_core_runtime_resume(struct device *dev) * after being reset in the lower power state by runtime-pm. */ ret = bmi323_init(data); - if (!ret) + if (ret) { + dev_err(data->dev, "Device power-on and init failed: %d", ret); return ret; + } /* Register must be cleared before changing an active config */ ret = regmap_write(data->regmap, BMI323_FEAT_IO0_REG, 0);