Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp192116pxf; Thu, 8 Apr 2021 00:20:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGTe8c1sRuir5Wez31J4ftJhcTLzUfd1q9TPLz38FZSQdhWXDRxMHTHekrCmdLcrD30QCP X-Received: by 2002:a65:6642:: with SMTP id z2mr6890199pgv.214.1617866434752; Thu, 08 Apr 2021 00:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617866434; cv=none; d=google.com; s=arc-20160816; b=EVMHhrW9Vsp/cz9Th923896BbsbYUK9aWZTsDNLOVR8SFKXL45yv2urNrbTYEp1QGE A2Xoa8glIIjyidwoqHEDYeTHbnw4TJSz4fsuyk7FNInaDAxa6lGhSHHYbQWc9erS/I/1 Ec/B79j4FG344ERYPy3sh/NhEdBza4Q8QjTLiGhpttLgQFPfsNdbv75fd68fi0mBshe6 cdLN4dUJfSUGeM9WhNf6qg48HyrL4Nw6FYMoTG+7zmDftSToUClkVaLsgl5IkHYiRVSY XuZ9c1PeXJqpZHNVZb47l0Xnh7+yRJZp4Hr1pjg0LYUHnoK/YkkFZL+mXSsVx+YSx7BC yXbQ== 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:cc:to:from; bh=fequViSBrDRiBKLH6zu2bJMuTgG4yyO5GCgbopIK0E0=; b=hGVrOK68Rkr53yYth/OBafRZoKk4xwpffsiio1HrZIdGHzxSitAala9dNJgdKKBLIn BVg7f7CCjI5GlsVNCZQCRF0m/Q/tZFNLv/pMNHhBz5XcQLz0rF0ZidmvYIusaJXnL+4t jltkdt58BsO10BkSi698Z3U3G5jQ0bxECg7OvvrsR4qeywKW+mDQP394mwTVnPm0B1Xj 7kq7Q4bzoaLlM7HGvAKLq4nsPrG5mqCunZx9/lvlzG4Yy+L//aV8+FreiOQ/kjSXwoVs k0/pxzOpU7bVu5IXkldRe+YQAbc1KpMZANR0pkvlIZd37z/lJpfnr2zCvPrIRxptdlQT kdoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si24898321pgq.405.2021.04.08.00.20.23; Thu, 08 Apr 2021 00:20:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230296AbhDHHTc (ORCPT + 99 others); Thu, 8 Apr 2021 03:19:32 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:16039 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbhDHHTa (ORCPT ); Thu, 8 Apr 2021 03:19:30 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FGCHM1pR6zPp7C; Thu, 8 Apr 2021 15:16:31 +0800 (CST) Received: from huawei.com (10.175.113.32) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Thu, 8 Apr 2021 15:19:09 +0800 From: Shixin Liu To: Herbert Xu , "David S. Miller" , Maxime Coquelin , "Alexandre Torgue" CC: , , , , Shixin Liu Subject: [PATCH -next 5/7] crypto: stm32/cryp - Fix PM reference leak on stm32-cryp.c Date: Thu, 8 Apr 2021 15:18:36 +0800 Message-ID: <20210408071836.836842-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.32] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pm_runtime_get_sync will increment pm usage counter even it failed. Forgetting to putting operation will result in reference leak here. Fix it by replacing it with pm_runtime_resume_and_get to keep usage counter balanced. Signed-off-by: Shixin Liu --- drivers/crypto/stm32/stm32-cryp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index 2a4793176c71..7389a0536ff0 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -542,7 +542,7 @@ static int stm32_cryp_hw_init(struct stm32_cryp *cryp) int ret; u32 cfg, hw_mode; - pm_runtime_get_sync(cryp->dev); + pm_runtime_resume_and_get(cryp->dev); /* Disable interrupt */ stm32_cryp_write(cryp, CRYP_IMSCR, 0); @@ -2043,7 +2043,7 @@ static int stm32_cryp_remove(struct platform_device *pdev) if (!cryp) return -ENODEV; - ret = pm_runtime_get_sync(cryp->dev); + ret = pm_runtime_resume_and_get(cryp->dev); if (ret < 0) return ret; -- 2.25.1