From patchwork Tue Dec 20 11:52:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 35044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2921904wrn; Tue, 20 Dec 2022 03:57:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5c88IuqvjHAnUBH03rDm1DqVtZaa2a0opixcRkWdeRWKE2I+fsdlEpn7x8so6hZ89vbpIZ X-Received: by 2002:a17:90b:2687:b0:219:c691:9925 with SMTP id pl7-20020a17090b268700b00219c6919925mr48333567pjb.7.1671537458166; Tue, 20 Dec 2022 03:57:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671537458; cv=none; d=google.com; s=arc-20160816; b=sS5CriXkU3FNbPAHdBYQmpwEXI2mj0V+qL+fKsLJVhZ+O8Ooopj4wDgJlGzKJKXWWm IFXPWestFH1WlHRIukX16K8UK+imZE46RTAMsoBkzjCvo/2WZhIyQAPnB1rNKx8zUyDG sgBvdmYRQFE1FFbim0KHM2jhTESJpxW8BxcvrJpnl5Ag4/YmPN4rHH369zgb/rm8lmEH ID6kR2UuyIfrFuSHzlhsfvKIyVQwA1j3y7Yl0ImqjLT/zFzoyu3gyFGO3TdlIGYHP9iU ALt8cP2LvD2phwGCTJWq/kL2MXGAk90MgM5SnJ9i1B1vettjmkyvru4T+/VT8I4M64hh 73zg== 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=Lso547JX5vTY2uG06uoFIFztgpYecJYWXqOFJKfCq9A=; b=WE8UqWFaoU2QbZ8aZFFtex/TOAKTHUMvv3td9+Z3ywKC0H2tkIYRJ4SKcAl2X2mtfm g74NxYVdj/kIcupRQ5I2Ejc72kPztiQDgKq4XgOgrJ8XBsvsMtI0JTWuxBKTr4UVgzfu ZOwBsOpkAiaKfoCOaj6Pymmufcg6wBC16t+uKnxVJGnG01sknKXNpA5Plv5EkUP3Qe3a 8FAhsFdWlnSU1+I6i0yKz+13zLQLlajkClIGTdS2MZ86ecc6oet1vySliNyXBTN9C+D0 bGE0UpsKHS/gGXn/pEBQrkUJRJHMXICNK4/epR0Pxp2AGhJ3n+KzOeZhEttQ4daq0Cq+ gHng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NZBmBWT0; 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 y9-20020a17090a644900b00213a3a2a09csi19042093pjm.159.2022.12.20.03.57.24; Tue, 20 Dec 2022 03:57:38 -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=NZBmBWT0; 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 S233217AbiLTLxD (ORCPT + 99 others); Tue, 20 Dec 2022 06:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbiLTLxB (ORCPT ); Tue, 20 Dec 2022 06:53:01 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A3163DD; Tue, 20 Dec 2022 03:53:01 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id m4so12022943pls.4; Tue, 20 Dec 2022 03:53:01 -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=Lso547JX5vTY2uG06uoFIFztgpYecJYWXqOFJKfCq9A=; b=NZBmBWT0pXX5TaRDccE1wmua0oWib2GxgHdFapwRZJovA6yEJLwSuHqnjdnlGzvdFx sbJoX6yb8Ubb1qa/54JSFrn8/KVPrk6Zgz6ksxwgK7Hge+QQx4JOp44XYTbyOv7c4QrN 9dmddS+pG07psJp1LojSHEDz6xCj+gviFXyTAPvuGbyard1kB/iP+sfVUeNMN05dsEKw a4LoQ/J+rOjMQgkXk7qHVIwsgnkqkVeZENxlDA/NMfH20WJ9u/+M3Di90NUfk9/r76RN 6+MJ9C/BG2GMl8fCxkMRohgwfz6z8QRM3msAgJv1RLsrde9Niq4pBZ11iPtgjvhGD3BP BX6A== 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=Lso547JX5vTY2uG06uoFIFztgpYecJYWXqOFJKfCq9A=; b=AGcuIoxtEJDvEqzVXux+3AKB9iqro+Iwq+zJA/Zy+29Jgs7BpgfcFObrPiDWSsP97e w34Rsmx4VNT75qip9xgDbPUGEBjoAgRKP4tzN9MVMeUH1BiY7VBP2osqairxI3dp2Pfp YVwUMbT+EgxiTU0g/G9jKUm4fAC8jG+sXgpXpQwC+nnu0rdKf0oIN7f5EzI+PkcOrZR/ yGKFrnvofaet+Ee2U+N7z9XZvex6PQIBNqMt4LQxvvp/3aZXp8GZAh6B9oJjcmPUn8jL TLztXZmyQ7oC/cWOc+ZZrcvbxoBSjFOK5J105u2DzPLXuSfn8/2l7LO60eAArnQfWssd CKCw== X-Gm-Message-State: ANoB5pkGisgo6dpC/Hr8TwzXBm2xhRDJhrJOqpNC0wYe4Z7gxT4saA5X gxanCK/BT4eEfS9UbBzlryc= X-Received: by 2002:a17:903:515:b0:189:ec2d:89c0 with SMTP id jn21-20020a170903051500b00189ec2d89c0mr46662475plb.59.1671537180573; Tue, 20 Dec 2022 03:53:00 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id j5-20020a170902c3c500b00172fad607b3sm9140276plj.207.2022.12.20.03.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 03:52:59 -0800 (PST) From: Miaoqian Lin To: Dmitry Torokhov , Florian Fainelli , Broadcom internal kernel review list , Miaoqian Lin , Rob Herring , Nicolas Saenz Julienne , Eric Anholt , linux-input@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] input: raspberrypi-ts: Fix refcount leak in rpi_ts_probe Date: Tue, 20 Dec 2022 15:52:43 +0400 Message-Id: <20221220115246.1522054-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?1752734061316600360?= X-GMAIL-MSGID: =?utf-8?q?1752734061316600360?= rpi_firmware_get() take reference, we need to release it in error paths as well. Add missing rpi_firmware_put() in the error handling to fix it. 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 --- drivers/input/touchscreen/raspberrypi-ts.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/raspberrypi-ts.c b/drivers/input/touchscreen/raspberrypi-ts.c index 5000f5fd9ec3..114237c76378 100644 --- a/drivers/input/touchscreen/raspberrypi-ts.c +++ b/drivers/input/touchscreen/raspberrypi-ts.c @@ -140,21 +140,24 @@ static int rpi_ts_probe(struct platform_device *pdev) return -EPROBE_DEFER; ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); - if (!ts) - return -ENOMEM; + if (!ts) { + error = -ENOMEM; + goto err_put_fw; + } ts->pdev = pdev; ts->fw_regs_va = dma_alloc_coherent(dev, PAGE_SIZE, &ts->fw_regs_phys, GFP_KERNEL); if (!ts->fw_regs_va) { dev_err(dev, "failed to dma_alloc_coherent\n"); - return -ENOMEM; + error = -ENOMEM; + goto err_put_fw; } error = devm_add_action_or_reset(dev, rpi_ts_dma_cleanup, ts); if (error) { dev_err(dev, "failed to devm_add_action_or_reset, %d\n", error); - return error; + goto err_put_fw; } touchbuf = (u32)ts->fw_regs_phys; @@ -206,6 +209,10 @@ static int rpi_ts_probe(struct platform_device *pdev) } return 0; + +err_put_fw: + rpi_firmware_put(fw); + return error; } static const struct of_device_id rpi_ts_match[] = {