From patchwork Mon Nov 29 18:26:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12693940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA607C433EF for ; Mon, 29 Nov 2021 18:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ETSPpCEPZHGJnsUr2Jg2DqJu4W7qgoDpbpoOGiVEMSs=; b=EKHOhHkM99QKGy Gr3bs2pX191oLhsq11N/Yfmzb++DZboCx5LyvTGVuuE/hXn4M342T1HjRkNksL0Rd45JjSQKOgYuz kQnfZ0xYhooTefdqzpGMRzJ1qfL2nNQqkSe+SjSxd5Zf3JtvRtnoKW+0+eZ/6j7vvp/t48DmYjfsx Csnck/On48y9rdHptjQ8uYCM48Kevk7DqQpz+++/mHjzpUCmlP/0EVcPAjlgJT8qfLRFr6KhDn7IK pnlw3V7UkzK56SYGhYnRlnZvshYfs/3jE9wKR7y7454DEP/B3UieHgnVmCM+OA4X+sZ7OEvR/c4Z+ FUzqAfLI8tTDBoaPA8Cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrlMk-001lF9-Qb; Mon, 29 Nov 2021 18:27:03 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrlMO-001l0s-NB for linux-arm-kernel@lists.infradead.org; Mon, 29 Nov 2021 18:26:41 +0000 Received: by mail-wm1-x334.google.com with SMTP id k37-20020a05600c1ca500b00330cb84834fso17606537wms.2 for ; Mon, 29 Nov 2021 10:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BpKcc9rm5rbzAZatIAOzggrBDPf3twFeL6olSbnXxPU=; b=EZ2uJ0rggm5rd6nlRpQ3ZxOHTGwskWknuwJ6X+/H7KG8oZmW/z/QRYVDK9o7wjR+hy idmmsd17KgTQuF2MQoR3LbzYlRh7cufHoCaby3K8ycNUnFl4bKxdAh5yp6f5s3uLTML2 4dRkc0LvnTVeZ0RlH+4BzsFK+dxwrxBEZN8X5PFIwAzYTs9Bdg5N8X73gT+ozxFexXU/ MUCK+tIQUasz5ngu+sOyUIm03pUYuy4+cAj3sFeasL9anUiNtCYlqsv20PU8RAsJmHJJ VixmPiqpOPz++oel9+YKVCLs4Hj0525uVrxJaQl3Uiyca3H74nC8Hn6tlaavFPUQgqe7 x4Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BpKcc9rm5rbzAZatIAOzggrBDPf3twFeL6olSbnXxPU=; b=GRRCutgQZNBDLf5wrfX0DXzEY3IPVIbtKsK2yi37ci71zmMzY7oAK+4/Jz4nfm5AFe a0nYnRxJeDutsmBCErdjoTyaXY3SWX/v3GYuOkZxkfbPXSJ6vdkUfSrZZ3vuuc39r0IK UrtGvRtJuuEj5u+OuFtLZgCGrXDbI26J4H5lQfp3NJTWvdFbfvMDp8jazBdB4k1zmlUy FMeSNPMjfJGNSgKcOyPv9rmZVSz4d5apj3EU2xxk1FLC+y4bND5p7ErPMhgBRvwuna1q CN4LMZwk4cEr2Fi45EypLLv61KI8t1bxfJkRlglQ8uYIgHQ6cYg6R1cBGHGbT9RrYnTB Q6fw== X-Gm-Message-State: AOAM530MSdw0ZToNw2H9BUE4wJ6EWgH/8x+itJ4QhUPz5Z2WUAIeuokB S/ZgyokXFGCDoTbl83QGwCE= X-Google-Smtp-Source: ABdhPJwaFk4yVUq5kkGJf2GasjPsTe3ndZ0bAmMTH8Ot4orQxTQlScuG9Re3xVxW2eh9++aRYdlK/Q== X-Received: by 2002:a05:600c:3846:: with SMTP id s6mr20926wmr.55.1638210398970; Mon, 29 Nov 2021 10:26:38 -0800 (PST) Received: from kista.localdomain (cpe-86-58-29-253.static.triera.net. [86.58.29.253]) by smtp.gmail.com with ESMTPSA id o12sm85907wmq.12.2021.11.29.10.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 10:26:38 -0800 (PST) From: Jernej Skrabec To: linux-media@vger.kernel.org Cc: ezequiel@vanguardiasur.com.ar, nicolas.dufresne@collabora.com, mchehab@kernel.org, robh+dt@kernel.org, mripard@kernel.org, wens@csie.org, p.zabel@pengutronix.de, andrzej.p@collabora.com, gregkh@linuxfoundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Jernej Skrabec Subject: [PATCH v2 1/9] media: hantro: Fix probe func error path Date: Mon, 29 Nov 2021 19:26:25 +0100 Message-Id: <20211129182633.480021-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211129182633.480021-1-jernej.skrabec@gmail.com> References: <20211129182633.480021-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211129_102640_777012_95516AAC X-CRM114-Status: GOOD ( 12.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If clocks for some reason couldn't be enabled, probe function returns immediately, without disabling PM. This obviously leaves PM ref counters unbalanced. Fix that by jumping to appropriate error path, so effects of PM functions are reversed. Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver") Signed-off-by: Jernej Skrabec Acked-by: Andrzej Pietrasiewicz Reviewed-by: Ezequiel Garcia --- drivers/staging/media/hantro/hantro_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index ab2467998d29..3d3107a39dae 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -981,7 +981,7 @@ static int hantro_probe(struct platform_device *pdev) ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks); if (ret) { dev_err(&pdev->dev, "Failed to prepare clocks\n"); - return ret; + goto err_pm_disable; } ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev); @@ -1037,6 +1037,7 @@ static int hantro_probe(struct platform_device *pdev) v4l2_device_unregister(&vpu->v4l2_dev); err_clk_unprepare: clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks); +err_pm_disable: pm_runtime_dont_use_autosuspend(vpu->dev); pm_runtime_disable(vpu->dev); return ret;