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 921C724A06A; Mon, 13 Oct 2025 14:51:55 +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=1760367115; cv=none; b=Kwrwny9YnlsucJA+7CNUfE/DMJRdkuN6pjIz7c/fTNRDTmqPtq6BgnPKkD1LJWlTFNEJC8dp5NjM6wHylcIGyO4qEUHiIIX12OkAu6pdEC2TySAytMSjKKZ06UKOWOSiOU3w0ApTrbzzbxkO6+LhXhpGLBiA1TwoZW0OCMzOelY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367115; c=relaxed/simple; bh=/lyBYK2cTBV9j7kzzmHHkIG7qJ9+7vBaFkJRjQ0ezOo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nLEMkeC53iTOfj1Tx28Vtz6X/9CL7XG759EkoeDF86zs8HDcIe2Mqgt7wckoHKbm0raulxLzynKrGedgRnHU92INDAV+RoK3xtMu534WdI0yAC34Yq9MY8poxScvHwSNc/yBJDQwXV7XfSaKO1QQrU22gMqi4qTgDdtHRhJAYqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XN/l4i/V; 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="XN/l4i/V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAB76C4CEFE; Mon, 13 Oct 2025 14:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760367115; bh=/lyBYK2cTBV9j7kzzmHHkIG7qJ9+7vBaFkJRjQ0ezOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XN/l4i/VZeG+LIAhdjuyaizHOm1knistfTRF2W8DEMZO6LDb6O5Lp9Rvl6gXdxvkr K8OTj/K0fZMDbnS7rE58TTIhs//iliQ2UmLnpY4SniaYLA02FFBmfCNY3Uh/PBQUsx gRZFvSMrZqNg5O4n2UAKUf9J9JS7qp34lidetiKA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhang Shurong , Jacopo Mondi , Sakari Ailus , Hans Verkuil , Sasha Levin Subject: [PATCH 6.1 098/196] media: rj54n1cb0c: Fix memleak in rj54n1_probe() Date: Mon, 13 Oct 2025 16:44:31 +0200 Message-ID: <20251013144318.244844875@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013144314.549284796@linuxfoundation.org> References: <20251013144314.549284796@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhang Shurong [ Upstream commit fda55673ecdabf25f5ecc61b5ab17239257ac252 ] rj54n1_probe() won't clean all the allocated resources in fail path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to prevent memleak. Fixes: f187352dcd45 ("media: i2c: Copy rj54n1cb0c soc_camera sensor driver") Signed-off-by: Zhang Shurong Reviewed-by: Jacopo Mondi Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/i2c/rj54n1cb0c.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/rj54n1cb0c.c b/drivers/media/i2c/rj54n1cb0c.c index 1c3502f34cd37..86f4971222ba7 100644 --- a/drivers/media/i2c/rj54n1cb0c.c +++ b/drivers/media/i2c/rj54n1cb0c.c @@ -1332,10 +1332,13 @@ static int rj54n1_probe(struct i2c_client *client, V4L2_CID_GAIN, 0, 127, 1, 66); v4l2_ctrl_new_std(&rj54n1->hdl, &rj54n1_ctrl_ops, V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); - rj54n1->subdev.ctrl_handler = &rj54n1->hdl; - if (rj54n1->hdl.error) - return rj54n1->hdl.error; + if (rj54n1->hdl.error) { + ret = rj54n1->hdl.error; + goto err_free_ctrl; + } + + rj54n1->subdev.ctrl_handler = &rj54n1->hdl; rj54n1->clk_div = clk_div; rj54n1->rect.left = RJ54N1_COLUMN_SKIP; rj54n1->rect.top = RJ54N1_ROW_SKIP; -- 2.51.0