From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 EE87340489A for ; Thu, 9 Jul 2026 09:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783588722; cv=none; b=pOW88+tR+0Zr5H4vr9VOueghkSVD5O+f80KOBaXpS82Pj1ffJiEwvLAV0DLsIumHu45YLf2/YyBpwJ4UJGbFi9piGyhyqQNDEl71iZotnRfVrW9jPd45RotXwVxz9RQkVEcd6UXabIqcB51XcNmNM4TWvQz4Y8yCJn0vQ9wib/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783588722; c=relaxed/simple; bh=6aXmXSq8GQYanDP78vf5EjCk51ZJZSfKqMGIqlbuf6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rx5HDUvPKMwIk2FbtwpBs5NwVgHjhEJiTe+D02fZyoPEqqEsgTrBclZ9ozSlcWRIMEef6y7lhlt/Wy9Y+YLFleOe+cAWYmqeBZszLmdXmi6QAvMZFHzONWgPclQOx24Qkh5O4TYGxoLHwZ3SZT/VlCxnSVbFDOqYi+rH6izsFMQ= 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=PXQX+uCg; arc=none smtp.client-ip=209.85.210.175 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="PXQX+uCg" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-848593533cbso470465b3a.3 for ; Thu, 09 Jul 2026 02:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783588719; x=1784193519; 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:content-type; bh=zT2kkT7n4+UHqEX9mqNgvpGllnQYoMihdqd9pN3gqWE=; b=PXQX+uCgBTV3eKOiLdQLO1mqc6rmS369AFb5LzDua889t6+JOnWlO2Y/GVVl6kCjUP rQMIzu201AUnvmwUHPyYrsUyDDfx5Z3nsTXR/cV62lBfKDoPHVZ37EW9mJJQ55dumXTv OrCMuMPmxcc90XAiTCosWKGR/Tm+f6QDhHB1SnyuazLFRapT7w91odyLDynHus49P7eG B8z8XzLvDSRmHmdZdsAcH/eEgAVo7b9fDi6PIUHrfQkIyLMolYcZJf9bTbQEiga6pvHu WeFgtILO1TH3Xzzj5uf1XC/AxqQ4YQq0R4C+tVhID1A28UBuZcXAGMhRnl+F7Ti81/O6 KMCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783588719; x=1784193519; 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:content-type; bh=zT2kkT7n4+UHqEX9mqNgvpGllnQYoMihdqd9pN3gqWE=; b=Nu/xxa7+Qt4OVykeqQcuaBT9OKAeeU+0u2NhELcxGbAHFyGENolEn+XUi4+imaxecI h6jZY5uLb1Zt21SbvT6l9CuW4N+fVg93Xe8Hae2NAvmYAfU/QAZIYNWg0KS/WVILp/pd B6jrwloX7H3KYs5IMeoszlPwqJnXcMLDj5WP7S+agKgsrhXCwTwuZ93xEq8KD14lOQQG hn30+ewmRL1klMN4uKDcV/LnjnQzB1E2azycKGzixp7UmCa2m9zQmyHfkPSRIo9xhpro 9CNNl35v417bpQ5V99iVvk+RJkuxAQkL/HXi+qFTvuVnoTf1PdZK75UDIzLi2K4IGwgX xa2Q== X-Forwarded-Encrypted: i=1; AHgh+Ro/FuBR1Jdw6expMuNpm9tecvoN1uDALEu/4zXejeyGqF4uA+5uOkV8c7nHCMbW5txvZ9RSQV3YAWz5vNo=@vger.kernel.org X-Gm-Message-State: AOJu0YytDmKTt5cjKPLp0wdA7c/9QUpF9bq6th+EAdKfqjRc67zqw4lS Hgvgt0ZyYXNvlnrEF69PFNK1nd7RrYg2t7KUT0OHFHoWLaPhkxc0Xq1l X-Gm-Gg: AfdE7cnqsICKB0eXGgG3S2xSzhL/Z1D6Dm8aUD7yhGtWkwjWMAx7rfBwol5dFyj2add ljUEyuxy/gXk8m/RjT+Z0tZpvxvPkN5qdRkTcjotlQBGyvYGfvlGbBShwwfGk6BdbuEGfRiDvHO aB75TPBKewsRhkzgUFxK/p10Xh47C28GMpnSVRSejz9BMt3OInFEvlYeXh+w9eOA73X0ISZIxhM IoxL20TSPVyJN79kbNmesvgUoOjTeWjcvwBr+fSJFByNKryoSA2OjcdhJ0VNGhj2xpymnVmWBuD /Awxjvi9FgP77OapkMox+YowC++B89ouo2hL7x3ieWGUM2a5Fw4s2VfewUBPL987kSzCCeBLRac NZWjZVgWXLzuKeE9wO0m/IvLbQBDHUYqx4QbzyUn8YCm4LLKWIqp+scL/M8n6dd5z6d1gPJUb5b 9QNsYmMPG5tHnf9ZK4fALPstbGicWxsA25u4MRpz/+76u+x5aJdx+v3w== X-Received: by 2002:a05:6a20:431a:b0:3bf:ab76:63d with SMTP id adf61e73a8af0-3c0bce1ae8bmr6548628637.11.1783588719122; Thu, 09 Jul 2026 02:18:39 -0700 (PDT) Received: from localhost.localdomain ([49.207.223.101]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b6594f6a9sm29682728c88.5.2026.07.09.02.18.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jul 2026 02:18:38 -0700 (PDT) From: Biren Pandya To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jacopo.mondi+renesas@ideasonboard.com, Biren Pandya Subject: [PATCH v6 4/4] media: renesas: rzg2l-core: Add missing media_entity_cleanup() Date: Thu, 9 Jul 2026 14:48:18 +0530 Message-ID: <20260709091813.67081-10-birenpandya@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260709091813.67081-6-birenpandya@gmail.com> References: <20260709091813.67081-6-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 media initialization error path and the remove function fail to call media_entity_cleanup() upon teardown. While currently a no-op, calling media_entity_cleanup() is an API requirement for entities initialized with media_entity_pads_init() to prevent memory leaks. Add the missing media_entity_cleanup() calls. Additionally, rework the error path in rzg2l_cru_media_init() to use an error_mc_parse label, ensuring that cleanup functions are invoked and the unnecessary mutex lock is removed. Signed-off-by: Biren Pandya --- .../media/platform/renesas/rzg2l-cru/rzg2l-core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c index 3c5fbd857371c..ee555b01c3aa1 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c @@ -230,13 +230,17 @@ static int rzg2l_cru_media_init(struct rzg2l_cru_dev *cru) media_device_init(mdev); ret = rzg2l_cru_mc_parse_of_graph(cru); - if (ret) { - mutex_lock(&cru->mdev_lock); - cru->v4l2_dev.mdev = NULL; - mutex_unlock(&cru->mdev_lock); - } + if (ret) + goto error_mc_parse; return 0; + +error_mc_parse: + media_device_cleanup(mdev); + cru->v4l2_dev.mdev = NULL; + media_entity_cleanup(&cru->vdev.entity); + mutex_destroy(&cru->mdev_lock); + return ret; } static int rzg2l_cru_probe(struct platform_device *pdev) @@ -312,6 +316,7 @@ static void rzg2l_cru_remove(struct platform_device *pdev) v4l2_async_nf_cleanup(&cru->notifier); rzg2l_cru_video_unregister(cru); + media_entity_cleanup(&cru->vdev.entity); media_device_cleanup(&cru->mdev); mutex_destroy(&cru->mdev_lock); -- 2.50.1 (Apple Git-155)