From patchwork Fri Dec 23 07:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 36157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp194756wrn; Thu, 22 Dec 2022 23:59:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvpCt+tuWLMNugjGzEoKGQfKFU/I6aiC0JOBxINX0hpDi/qJ1rtzmj7dXuxmbObBa0nVBsP X-Received: by 2002:aa7:8215:0:b0:580:9151:afe5 with SMTP id k21-20020aa78215000000b005809151afe5mr1888482pfi.22.1671782354705; Thu, 22 Dec 2022 23:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671782354; cv=none; d=google.com; s=arc-20160816; b=bgc5uZO9bDGWqYTYXprFMczkCTLh9QAIyJaOhOkKhuu/55eUa8vzeNFF0V4fiR8lsZ tVMQ4mMuah7R7ZTdDQ4wHPBQUeJ03GmOMmqO+z9NlqvXk/k0wE2cv9xjDiWRP1wa39N4 OhUz6/Jg5Q+ZlxdGcBC7SJ2/Z5Kmru7lXRzJbSoefIkFgJTnnFNXVkqQe6m25U0c/7rl mdwIHWU2C0oYE4LlfCNDQI4uGy99CXvDGeaHY2eZ6Jfd8CaTkL0nnJSG77Wk2b/1NhXk bkDMH75zWjIdpNfZ39F2oWPXHYLNSAoKK8XO1f/FKDUCChfIA8MC+oKReBVe8mPh9HCc Y52Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=YR55G9jjoRMMPsmodTNiLbx+TyjEdvtvdLYurZPfaN8=; b=svh2pEPlbBYcEtMBdzeCh6Nb2CfLZ2d02W9c8IE8pULNyqKkmsvQMsHYt8/A1qarS9 GRCvomSgASKFYchfAZnz2tI6nxiAR0D5I9ITB9whhurCxzs5bdcsEHvk+mC4x+6R551j GwKlvst81JRoZE7LlTqDTqAMO/UEFcFMPbWmLoR91wXS76Mp3bsn56U3AwIKSDsJa7p+ lwj3LadZPFLimbtUjtYXmZSZsLfiFvGUpXpCSEm9qlC/umSPY7ZT+M6tWPCt2xz03yyj 3H9cWnYqKg02WzGYnGmNL5TNh5zsKrzna/iQu36kx8qeRfClUwVk2qgp37ThgMjN8iQk n27A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o2QV5Ejf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u34-20020a056a0009a200b00576a51119c0si3282481pfg.179.2022.12.22.23.59.02; Thu, 22 Dec 2022 23:59:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o2QV5Ejf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235896AbiLWHrf (ORCPT + 99 others); Fri, 23 Dec 2022 02:47:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235881AbiLWHrd (ORCPT ); Fri, 23 Dec 2022 02:47:33 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E94430F46; Thu, 22 Dec 2022 23:47:32 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id v23so4275136pju.3; Thu, 22 Dec 2022 23:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=YR55G9jjoRMMPsmodTNiLbx+TyjEdvtvdLYurZPfaN8=; b=o2QV5EjfyGwQymBw3MiEVEiXoA9BcDha8F88P5QvkSg0GlCM2Y3uo0JzqLAhVB2s+O 5qOuTNMEdk8y8JioagUG7IRQoJhHf8OrwSSObO+dEW6uLf2W1Dy364CD10Zva7bZ7XGR Epam6lhOQuTDExs/R8NSV4MBwgvfwklMcu+CeR+8fNiQWlKQ/ndaEM4beM402UmSklbj u+KloBT+B8xQ3MqHzzQjZjc265cNLsD7Ra44FsJY9KX0oibk++Rx8yFjfqYR7QercVZv ATEfWNl6c6SK2C/t/azCvRA+uM+zcGMSw34/HXFIxml0c8uTPLw8LjSq4F8+y1dBUFCZ I1ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YR55G9jjoRMMPsmodTNiLbx+TyjEdvtvdLYurZPfaN8=; b=EeYcBP1Z1rQCkoblkAFa9lZ0I6QcPTChDs/xmSDM7xEoVlJJbcRoM/c8EGPycYrg3r /LYHj+8lCsriqjA6X/EOxvM4k95kTrTkTPvPMzo2ptE7OLUViplEqixLHBebrm3b5fTC W18qQvlTFTLVC6xknxye6LGfcGxSFqrr0sTXKTh8u3F4QIBoBi3rGx4zAvGjQstVvJFC lhZ2/r3jgG237+UaeOlTc+5oOkVJoyP6KR/71xkdJYYrGgJwUnLlzlNBFBq5CFaoRzmy RsqOPYn/caDdQupuPYzp21vB9XjkGgKyZuOjtO7rtluxz6kNyEZL6zV5AXQwHyreSpad cLFw== X-Gm-Message-State: AFqh2kpY9udMJvYvbf00IZMXhP9qPQ/5Xg1bjN0U650iGxa+stdWHwMH TY7am5Y96wwd/8F0Xgq76OouAgqInrDkkM35 X-Received: by 2002:a17:90a:ce8d:b0:219:34cb:476c with SMTP id g13-20020a17090ace8d00b0021934cb476cmr9682964pju.9.1671781651605; Thu, 22 Dec 2022 23:47:31 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id y15-20020a17090ad70f00b00218daa55e5fsm1699552pju.12.2022.12.22.23.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Dec 2022 23:47:31 -0800 (PST) From: Miaoqian Lin To: Dmitry Torokhov , Florian Fainelli , Broadcom internal kernel review list , Miaoqian Lin , Rob Herring , Eric Anholt , Nicolas Saenz Julienne , linux-input@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] input: raspberrypi-ts: Fix refcount leak in rpi_ts_probe Date: Fri, 23 Dec 2022 11:46:53 +0400 Message-Id: <20221223074657.810346-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752990854154436432?= X-GMAIL-MSGID: =?utf-8?q?1752990854154436432?= rpi_firmware_get() take reference, we need to release it in error paths as well. Use devm_rpi_firmware_get() helper to handling the resources. Also remove the existing rpi_firmware_put(). Fixes: 0b9f28fed3f7 ("Input: add official Raspberry Pi's touchscreen driver") Fixes: 3b8ddff780b7 ("input: raspberrypi-ts: Release firmware handle when not needed") Signed-off-by: Miaoqian Lin Reviewed-by: Mattijs Korpershoek --- changes in v2: - use devm_rpi_firmware_get(). - remove rpi_firmware_put(). --- drivers/input/touchscreen/raspberrypi-ts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/raspberrypi-ts.c b/drivers/input/touchscreen/raspberrypi-ts.c index 5000f5fd9ec3..45c575df994e 100644 --- a/drivers/input/touchscreen/raspberrypi-ts.c +++ b/drivers/input/touchscreen/raspberrypi-ts.c @@ -134,7 +134,7 @@ static int rpi_ts_probe(struct platform_device *pdev) return -ENOENT; } - fw = rpi_firmware_get(fw_node); + fw = devm_rpi_firmware_get(&pdev->dev, fw_node); of_node_put(fw_node); if (!fw) return -EPROBE_DEFER; @@ -160,7 +160,6 @@ static int rpi_ts_probe(struct platform_device *pdev) touchbuf = (u32)ts->fw_regs_phys; error = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF, &touchbuf, sizeof(touchbuf)); - rpi_firmware_put(fw); if (error || touchbuf != 0) { dev_warn(dev, "Failed to set touchbuf, %d\n", error); return error;