From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81819306B0A; Mon, 13 Apr 2026 16:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097571; cv=none; b=MTg/UmLkJBbLReMkdtmj98NV46x/Cv49TzNsdjBAr4l8gbmIJV0tlgNdpqfA65tv3Jxiy3PjLDbOnAraFSr+5BmpMHQDnyF+G+Xe+NRzqv6NxhpG/3WewAIgycYesvLbcEU/3jGw1gBKu4KDJO5N34eYrqb7qE/DU2BFgrZ1PZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097571; c=relaxed/simple; bh=EcOU2VTN+FxNV09sh24Lvj1PAGhAG5OfSb8ws5YzkP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cy+7e6dm0BP5nI5tl8j0qX9iD7GlErwv8TNfqzT7+75hG22y/NOrc+oAN/pPtXcOP4BIkL+shjrPRR4i/PgqW2xnlUxGPDBzTtWTyJl2PdMfUNPive/UWw9bW9LK7ib0F8jOiSdd4K+YqT1QmQ8Bya5C6MA+E+w92cChbyFuO5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NqLxvX+b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NqLxvX+b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19184C2BCAF; Mon, 13 Apr 2026 16:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776097571; bh=EcOU2VTN+FxNV09sh24Lvj1PAGhAG5OfSb8ws5YzkP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NqLxvX+bzBe/FhG2EBVCmsrpw38JpXzwY9dgVR05YhBLZWRiTlMDqaHuA/Mfe4Nvn X3wxyDWQb8CGEbr2i2plOURmWwW2m54bsNejbaNfx9VjoSaybrqwYFJJbIz7e2j4oK mq2k0DJQC/J0FGSLPqE+kWnLy4FIBXwNEtdYzwdo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Linus Walleij , Antoniu Miclaus , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.15 187/570] iio: gyro: mpu3050-core: fix pm_runtime error handling Date: Mon, 13 Apr 2026 17:55:18 +0200 Message-ID: <20260413155837.464467750@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Antoniu Miclaus commit acc3949aab3e8094641a9c7c2768de1958c88378 upstream. The return value of pm_runtime_get_sync() is not checked, allowing the driver to access hardware that may fail to resume. The device usage count is also unconditionally incremented. Use pm_runtime_resume_and_get() which propagates errors and avoids incrementing the usage count on failure. In preenable, add pm_runtime_put_autosuspend() on set_8khz_samplerate() failure since postdisable does not run when preenable fails. Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope") Reviewed-by: Linus Walleij Signed-off-by: Antoniu Miclaus Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/gyro/mpu3050-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -321,7 +321,9 @@ static int mpu3050_read_raw(struct iio_d } case IIO_CHAN_INFO_RAW: /* Resume device */ - pm_runtime_get_sync(mpu3050->dev); + ret = pm_runtime_resume_and_get(mpu3050->dev); + if (ret) + return ret; mutex_lock(&mpu3050->lock); ret = mpu3050_set_8khz_samplerate(mpu3050); @@ -652,14 +654,20 @@ out_trigger_unlock: static int mpu3050_buffer_preenable(struct iio_dev *indio_dev) { struct mpu3050 *mpu3050 = iio_priv(indio_dev); + int ret; - pm_runtime_get_sync(mpu3050->dev); + ret = pm_runtime_resume_and_get(mpu3050->dev); + if (ret) + return ret; /* Unless we have OUR trigger active, run at full speed */ - if (!mpu3050->hw_irq_trigger) - return mpu3050_set_8khz_samplerate(mpu3050); + if (!mpu3050->hw_irq_trigger) { + ret = mpu3050_set_8khz_samplerate(mpu3050); + if (ret) + pm_runtime_put_autosuspend(mpu3050->dev); + } - return 0; + return ret; } static int mpu3050_buffer_postdisable(struct iio_dev *indio_dev)