From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F5C8C433E0 for ; Sun, 14 Jun 2020 03:34:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 541F32080D for ; Sun, 14 Jun 2020 03:34:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=umn.edu header.i=@umn.edu header.b="RCPqZHOT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbgFNDdy (ORCPT ); Sat, 13 Jun 2020 23:33:54 -0400 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:44134 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbgFNDdx (ORCPT ); Sat, 13 Jun 2020 23:33:53 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 49l0S10FCHz9vJs7 for ; Sun, 14 Jun 2020 03:33:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nYz6heOXR9pF for ; Sat, 13 Jun 2020 22:33:52 -0500 (CDT) Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id 49l0S05j5Bz9vJrG for ; Sat, 13 Jun 2020 22:33:52 -0500 (CDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mta-p7.oit.umn.edu 49l0S05j5Bz9vJrG DKIM-Filter: OpenDKIM Filter v2.11.0 mta-p7.oit.umn.edu 49l0S05j5Bz9vJrG Received: by mail-il1-f199.google.com with SMTP id k63so6961342ilg.17 for ; Sat, 13 Jun 2020 20:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=XJ6IMqjGiHhE6cmEbhidHkelmuGZ0N00fySDcl0BZ0Y=; b=RCPqZHOTlWV3l7+1oiYCxljpHmbk3Vk2FFESqIGIuZYEKlFcK7H5LrOb23XIzkcQeZ WhM1b5WXU6vzr/g+HtvHM472+dxGp6yLvE/3q58mlhvXk3Aflwnhf0aiKXqQEXszg+oW X1aKtOp9qoZD5YMEP+Ea47OrYOM/9X6v68pZfo3sNZyhxVKG2CQ2Klf2L5161j8c6fj4 Qres46gtzoPMvxS/4lGvKcU53HeXhUSW9wZjtIZSNw/XLpkZOjhFuN4+eLFlnLgo68pj MoAsFtlisAtqLggUlmwL9fRYb2uBWUyV7froQVfnLzzFLNe2I6oAUj0YePngSworYW+O O7zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XJ6IMqjGiHhE6cmEbhidHkelmuGZ0N00fySDcl0BZ0Y=; b=GG8bwEsKsiOO5DbnmvmMv2pSNi9xyk38FE0kYcSRQkASr18Jyhoj7GAGpc1g0veh/I X9pIyi/CVge78fwCbJi4Kp1GqB8Fh1ZacsWrfJVSGFopPCkErDQIb+Sjl+p+Ulv2giAh m3eYt6nc96z5JmQcSAN5y3ioHj6Smge7mD0jMOecFHcTbfoagTQmgq0kUFBT9Jpy4o7C 2CcQX3EpNNLPW3WyfONDBagPRlgOC0P9YfuvaNuLnyXstfZ4c5/K72zNXBCx4JD8xsCL TIho8sB7ths8VZz8urmvVJa71ohGeispS0cSNzsQ6Shoj5ZsE4uiVQcEJCIrWeh1X1AD UzNw== X-Gm-Message-State: AOAM530IQ6mUKCDCBpCTrgdzDAUpKeLjuPlip24qivg/Wl2DbEs7W3Hw VOJtYskdxQJnTHGOKOnlWz0I/1+0/lT02iKzmlB2XVjCznxibtPtZKmqR5m9d691bve/46E7gyJ WYTuaMoxhm3/E8hpj/lwPY4Ca7ZP5 X-Received: by 2002:a05:6602:2e05:: with SMTP id o5mr21472143iow.28.1592105632397; Sat, 13 Jun 2020 20:33:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyQxM25g4plSaC+vGKbkygobkILoafY5rQEhoKV/Z8/cZP1AgGP3MWxJz/Yj++R/EZwGS9KQ== X-Received: by 2002:a05:6602:2e05:: with SMTP id o5mr21472135iow.28.1592105632167; Sat, 13 Jun 2020 20:33:52 -0700 (PDT) Received: from qiushi.cs.umn.edu ([2607:ea00:101:3c74:4874:45:bcb4:df60]) by smtp.gmail.com with ESMTPSA id 4sm5763940ilc.34.2020.06.13.20.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 20:33:51 -0700 (PDT) From: wu000273@umn.edu To: kjlu@umn.edu Cc: wu000273@umn.edu, Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: img-parallel-out: Fix a reference count leak Date: Sat, 13 Jun 2020 22:33:43 -0500 Message-Id: <20200614033344.1814-1-wu000273@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiushi Wu pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error code, causing incorrect ref count if pm_runtime_put_noidle() is not called in error handling paths. Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails. Signed-off-by: Qiushi Wu --- sound/soc/img/img-parallel-out.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/img/img-parallel-out.c b/sound/soc/img/img-parallel-out.c index 5ddbe3a31c2e..4da49a42e854 100644 --- a/sound/soc/img/img-parallel-out.c +++ b/sound/soc/img/img-parallel-out.c @@ -163,8 +163,10 @@ static int img_prl_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) } ret = pm_runtime_get_sync(prl->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(prl->dev); return ret; + } reg = img_prl_out_readl(prl, IMG_PRL_OUT_CTL); reg = (reg & ~IMG_PRL_OUT_CTL_EDGE_MASK) | control_set; -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FB7CC433DF for ; Mon, 15 Jun 2020 06:29:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2841120707 for ; Mon, 15 Jun 2020 06:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="g5nk5p+1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=umn.edu header.i=@umn.edu header.b="RCPqZHOT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2841120707 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=umn.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9E19C1660; Mon, 15 Jun 2020 08:28:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9E19C1660 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1592202549; bh=qt1Oxwmr6kui0cYxkhiHpXSs6xtgBLPPFgmcWgX0wEQ=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=g5nk5p+1l268kLlQ3FPzKgVdeICE1FtBPFvmJ8zwL6GaiDT2/3XZaubJegLuWxS/f 7LCu7kJ7gBqVOI3WCv4AGkjv0Cva5z88ceOzRg0fho/vqYWbWkwCpbLDVAKrCHXqAQ wEMArP0tnZI8nv2o/lES+qRNCrSvBOfpEE+Vwe6E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B2596F802A8; Mon, 15 Jun 2020 08:26:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AA5DFF8022B; Sun, 14 Jun 2020 05:34:04 +0200 (CEST) Received: from mta-p8.oit.umn.edu (mta-p8.oit.umn.edu [134.84.196.208]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2E308F800CD for ; Sun, 14 Jun 2020 05:33:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2E308F800CD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=umn.edu header.i=@umn.edu header.b="RCPqZHOT" Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 49l0S14xHyz9vbsb for ; Sun, 14 Jun 2020 03:33:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tJTk_0-Ce93R for ; Sat, 13 Jun 2020 22:33:53 -0500 (CDT) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id 49l0S136CZz9vbsT for ; Sat, 13 Jun 2020 22:33:52 -0500 (CDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mta-p8.oit.umn.edu 49l0S136CZz9vbsT DKIM-Filter: OpenDKIM Filter v2.11.0 mta-p8.oit.umn.edu 49l0S136CZz9vbsT Received: by mail-io1-f69.google.com with SMTP id b30so8960735ioc.8 for ; Sat, 13 Jun 2020 20:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=XJ6IMqjGiHhE6cmEbhidHkelmuGZ0N00fySDcl0BZ0Y=; b=RCPqZHOTlWV3l7+1oiYCxljpHmbk3Vk2FFESqIGIuZYEKlFcK7H5LrOb23XIzkcQeZ WhM1b5WXU6vzr/g+HtvHM472+dxGp6yLvE/3q58mlhvXk3Aflwnhf0aiKXqQEXszg+oW X1aKtOp9qoZD5YMEP+Ea47OrYOM/9X6v68pZfo3sNZyhxVKG2CQ2Klf2L5161j8c6fj4 Qres46gtzoPMvxS/4lGvKcU53HeXhUSW9wZjtIZSNw/XLpkZOjhFuN4+eLFlnLgo68pj MoAsFtlisAtqLggUlmwL9fRYb2uBWUyV7froQVfnLzzFLNe2I6oAUj0YePngSworYW+O O7zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XJ6IMqjGiHhE6cmEbhidHkelmuGZ0N00fySDcl0BZ0Y=; b=fjytxkpzA+rTk9Tf5jcVVgQ+Hn1B0JNnV3tEuXU326dptk2xz3xmIvN6PT4DvzPHgh z9tps0mByl7Y27Lyy+Ok93huxaSIh6RMJ4rXZURWdrNJTCdr4uFZA/hLvy3SCOxt2TqI dtPgH8H3qreTrtto3YE28Ssyh6L4kHMeXkApCmACOuVL/NOfidmT500Fr+Ud8t/gn2B7 BgBLwSDfMGHCIZRLGcy43vm0mQAtctimXhLjgpdGeXmXJM47bqTVSAvL18oSIQeoH3Am VIJvRaQZgQmaCLeThXDJJxqdlRVMecuk1ubB/TGrRUOKQ3e8DzPGEAXdfB8J+XXD5POj u4+A== X-Gm-Message-State: AOAM533v5Jwsyj+FvqIAL/YtkdC0FiYMcGtdNAk2tf127vHXS/EgAqqx VF0+MyJEsYVzkwdSnv1C387qEIoMHk6Btzv2jEia0Q2GHL+qiiHp2FtX9JU6E/W6bDW4XB4Ij6W e4PuVghraumws0bWuZ9LAGP0Bvko= X-Received: by 2002:a05:6602:2e05:: with SMTP id o5mr21472155iow.28.1592105632516; Sat, 13 Jun 2020 20:33:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyQxM25g4plSaC+vGKbkygobkILoafY5rQEhoKV/Z8/cZP1AgGP3MWxJz/Yj++R/EZwGS9KQ== X-Received: by 2002:a05:6602:2e05:: with SMTP id o5mr21472135iow.28.1592105632167; Sat, 13 Jun 2020 20:33:52 -0700 (PDT) Received: from qiushi.cs.umn.edu ([2607:ea00:101:3c74:4874:45:bcb4:df60]) by smtp.gmail.com with ESMTPSA id 4sm5763940ilc.34.2020.06.13.20.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 20:33:51 -0700 (PDT) From: wu000273@umn.edu To: kjlu@umn.edu Subject: [PATCH] ASoC: img-parallel-out: Fix a reference count leak Date: Sat, 13 Jun 2020 22:33:43 -0500 Message-Id: <20200614033344.1814-1-wu000273@umn.edu> X-Mailer: git-send-email 2.17.1 X-Mailman-Approved-At: Mon, 15 Jun 2020 08:26:10 +0200 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Mark Brown , wu000273@umn.edu X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Qiushi Wu pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error code, causing incorrect ref count if pm_runtime_put_noidle() is not called in error handling paths. Thus call pm_runtime_put_noidle() if pm_runtime_get_sync() fails. Signed-off-by: Qiushi Wu --- sound/soc/img/img-parallel-out.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/img/img-parallel-out.c b/sound/soc/img/img-parallel-out.c index 5ddbe3a31c2e..4da49a42e854 100644 --- a/sound/soc/img/img-parallel-out.c +++ b/sound/soc/img/img-parallel-out.c @@ -163,8 +163,10 @@ static int img_prl_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) } ret = pm_runtime_get_sync(prl->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(prl->dev); return ret; + } reg = img_prl_out_readl(prl, IMG_PRL_OUT_CTL); reg = (reg & ~IMG_PRL_OUT_CTL_EDGE_MASK) | control_set; -- 2.17.1