From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 0B74B391E44 for ; Mon, 15 Jun 2026 21:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781557471; cv=none; b=W3Rjq4e4pp1b6kNtLfTNYAzrXsNduhjrxMclHe5oOMXQ8K0hAxWxvxpWZZNmYbe8JjSr5UkQ2SjR2OBH7k7Y5gTMTP3Cbcosmljs4FPPz/7vklfNnoT5CVUof5Hob6R/a3Jb3I3V/BgqSmtDnO6Ra0RjUYmUfWJgqp5re9CkuZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781557471; c=relaxed/simple; bh=lL19Gx6NTY1hf9dAI3v6q8ep3YVk2DR6hugL/sunLsY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rzK2wKXdEykcI0DNmbnrVPZbp+hKf+rBP7fchwT/fhD4BbpWJ49WNtWsyEVf2C1tBMRdhgf9sHbLKzbGNOsQwcqfjA+LB0cg59jH1SoT5CSVyBn2vQgw+JFwYHG0HevmV4ng0p2g0vW95lpMn1A+3nJky7P6x9lVf6uBz3cevvg= 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=NgbA7YaZ; arc=none smtp.client-ip=209.85.214.174 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="NgbA7YaZ" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2bf237e1433so46678865ad.1 for ; Mon, 15 Jun 2026 14:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781557466; x=1782162266; 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=c3xaPaokdrS5QLN2+7BdcQffIRT1g0s1bcjgnu2FVGA=; b=NgbA7YaZhQago7L0OTAHi5kqPj0gqOqQCBNBDFewoiEeZQA9B9K5tU9HXNzuG6TAPA 1fq6KTpFIbOudnwLmqi05FUzXlYtt2HzBdcQnsD6z3y+8MWXfosFW20YsEhuYhKwGDLy HHuoRsGqJuwwhRfMrqL05hWlPtZ7uy14gyTg9hq/m8IbvL80PZHEAL+r0dEUJ2k4anMZ v2jAKwbYCrBwNL60mWY6TVGalKx50mUvLqzl90zWQcaOiHiTaUz0c1+9Faeh5rRjq7jG ipDhLjligy3OPugYZY+489B5Dl9Q4PPhcmtwT1QF110NPuDWnz/9SgcxyfI08SfbBymc 9D9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781557466; x=1782162266; 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=c3xaPaokdrS5QLN2+7BdcQffIRT1g0s1bcjgnu2FVGA=; b=povwACyNxfJ/UJLu/GrZy8zaoKxacRfoHuucMUqoSVOjX+aDLZszq1teKym01gVU+D ws9eBNYqqhJhaUzhpGyxDSxX5Y1KP+9k2W5LzjyvuwVUqfHsWDVv63gLBWhrUNNysz0k 45BcXZPdsGKSrQ9N0ikmsbMUDd0T8l8WjgLMExCdJ4D1kyuv0Tc2sfulcUWo5m27n7FU /yXg5NKQfOou9EXmpvbn49eFzIH5fzZUt2sdAz1oALQJTJXKzkrGYDUBBkmvufFhhvmb 0cBhhhMP5ZCJl5yO1+sCW9T3GYYEMCHqBdaRk7H5ImVx02Q8s8EIcayWqaUXfpxFG2na gWFQ== X-Gm-Message-State: AOJu0YwJwmfuZjQ8vznlJ03j6KcryHA0nP9SK2/BVkYsfB4zCSsPUGVG 0yoTY2K2jKJOOYRCEyAwJaAbTokNqOZMVJkFQ9Gapj3t8kOQKFd3Ivdo X-Gm-Gg: Acq92OEopz7Z11c+BQFVcJr5nT8YU7nLUeuAthR84OLvoZpKtjq+sutnzyNSFwVrOk7 xYLJiPJAsjyGyhxtgjSP3Bk1cUPYDPsag9UtnRceRkFyvwuke4UDwMfgJPEZ4OG4PodkidciRLL pWCfVJEwc25xec6igyziYCOn3R/Keh3ZmlsjGLby0Q5PWGtTE93nkYb8UNf7AKE3hKg6LXSOGrR zUWM3sFYBaPnK///6qN0qdLQNzqXVwRbvtVi+jeMFQAc0SrkHcK682Kix2ZZXeAJIVlR/3sOZvs yqzJ6DVUC1gSWQFCbZWdb9TvamXleDFddeHwJQLxdcgg4cZeq88BR4fJHy7A+TLwwHy0qoTPnvG 3TtD0/6f79VOHMfdBSpVnzQZH3i2miZiuMh+eTa8TNZ6kQED0mDOJqqw5BPcpPkfzcbFrf2zFF6 kH+7AwNylLeX8IpXgXNOEQbN1Rt1ddjVNzxg4hxV6SlEENgnVkFqKb X-Received: by 2002:a17:902:ea07:b0:2c0:d91d:c3e8 with SMTP id d9443c01a7336-2c41050b2aamr180117105ad.4.1781557466323; Mon, 15 Jun 2026 14:04:26 -0700 (PDT) Received: from localhost.localdomain ([49.207.217.37]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c433747ef4sm110934085ad.82.2026.06.15.14.04.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 15 Jun 2026 14:04:25 -0700 (PDT) From: Biren Pandya To: Sakari Ailus , Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Biren Pandya Subject: [PATCH 2/2] media: i2c: ov7740: Fix unchecked pm_runtime_get_sync() in remove() Date: Tue, 16 Jun 2026 02:34:12 +0530 Message-ID: <20260615210412.34567-3-birenpandya@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260615210412.34567-1-birenpandya@gmail.com> References: <20260615210412.34567-1-birenpandya@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 ov7740_remove() function unconditionally called pm_runtime_get_sync() but completely ignored the return value. If the device was already in an error state or disconnected, this could lead to an unbalanced PM runtime usage count or attempt to communicate with an unresponsive device. Replace pm_runtime_get_sync() with pm_runtime_resume_and_get() to ensure the device actually resumed before attempting to issue I2C power-off commands, and safely put the PM runtime usage counter. Signed-off-by: Biren Pandya --- drivers/media/i2c/ov7740.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c index 62c124a1353a..6b81882da307 100644 --- a/drivers/media/i2c/ov7740.c +++ b/drivers/media/i2c/ov7740.c @@ -1115,17 +1115,20 @@ static void ov7740_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct ov7740 *ov7740 = container_of(sd, struct ov7740, subdev); + int ret; v4l2_async_unregister_subdev(sd); media_entity_cleanup(&ov7740->subdev.entity); ov7740_free_controls(ov7740); - pm_runtime_get_sync(&client->dev); + ret = pm_runtime_resume_and_get(&client->dev); pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); - ov7740_set_power(ov7740, 0); + if (ret >= 0) { + ov7740_set_power(ov7740, 0); + pm_runtime_put_noidle(&client->dev); + } } static int __maybe_unused ov7740_runtime_suspend(struct device *dev) -- 2.50.1 (Apple Git-155)