Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2066830rwb; Fri, 2 Dec 2022 05:10:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf6KgSUQLFavUF8ODFFJfwCPeFrJrx9yvP9LQzeTLEBOEzcvlf9Y/beM5pel4ZVyVpvrwZ/B X-Received: by 2002:a17:906:ce2b:b0:7c0:cc7e:c783 with SMTP id sd11-20020a170906ce2b00b007c0cc7ec783mr1110720ejb.133.1669986641252; Fri, 02 Dec 2022 05:10:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669986641; cv=none; d=google.com; s=arc-20160816; b=veOSM+iHOgfVqqVkyVFLXOZbAQH7jxn82X9hEKZP1L/uxP/frMbJmy9PMqbDKJOnKY B6lRe6hty0awzSqe35w1OHx7FgF5QWnouWcSY+znVOm5fKsO8c34PPqHvOE8ZT/mkidI 6hzI4bbW3n9hxmTL25t9l+M3h8LAu995MADZxru2qYLQyjRPR1qKOWxSAQRoOqKHSrv7 j0Rkhug7a7FWgdTgFlLtcj7aIBxQ/BE2rsvklBTmjyTIBaWAU1VSASDxPJGRoPufhYJ+ XFGVKg1qVrZyKm2nsI2GhfFUpbXjMg/ZuX3Z9HnwF5G/R3dSKkhYtnYpvOsqJsOqpG/u 3H9w== 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=mfL9o2uKPQKOad+nSKb+uFwWcgPjUtoEeEtK/ol9gX4=; b=C0XqvPLVb3icPKUirAgOx6K0JliwWKjtRa4GGmPhWm5Z0lW1ClJuAwrdtowg4cOoIv 3X8QvyioDMOd43Gqn//ScwchdHhOvX7Ijc/+l9p7BIDsx4h6Knk6+po4nkbqE5kuu9hF IivyNhmX+iDMKyEGBE1FeiYe2VjLusSwNmsIpgg540/31T3qu20u+B9ClaCa9VSCA3ia EM19DQklEQmoerldoxPiEI7uzd9IVLpgg2RtP7xyIE9EZgccyH+NfUrbkFiUaVUzKh62 91kzcfBUyxtE1nZn2TRXvVpX6HsMYqmocU5Itbdf6cbCkz0k5+vlOX0ydJnOnbV+IktQ ejXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a1709064ac100b007add0c2ee2csi4704013ejt.924.2022.12.02.05.10.17; Fri, 02 Dec 2022 05:10:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233651AbiLBNFO (ORCPT + 99 others); Fri, 2 Dec 2022 08:05:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233659AbiLBNFM (ORCPT ); Fri, 2 Dec 2022 08:05:12 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92CB5D757B for ; Fri, 2 Dec 2022 05:05:11 -0800 (PST) Received: from dggpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NNtST4Tc8zRpFJ; Fri, 2 Dec 2022 21:04:25 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 2 Dec 2022 21:05:08 +0800 From: Xiongfeng Wang To: , , , , CC: , , Subject: [PATCH v2 0/2] hwrng: Fix PCI device refcount leak Date: Fri, 2 Dec 2022 21:22:32 +0800 Message-ID: <20221202132234.60631-1-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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-crypto@vger.kernel.org for_each_pci_dev() is implemented by pci_get_device(). The comment of pci_get_device() says that it will increase the reference count for the returned pci_dev and also decrease the reference count for the input pci_dev @from if it is not NULL. If we break for_each_pci_dev() loop with pdev not NULL, we need to call pci_dev_put() to decrease the reference count. Add the missing pci_dev_put() for amd-hwrng and geode-hwrng. ChangeLog: v1 -> v2: 1. fix error in amd_rng_mod_exit() 2. also add refcount leak fix for geode-hwrng Xiongfeng Wang (2): hwrng: amd - Fix PCI device refcount leak hwrng: geode - Fix PCI device refcount leak drivers/char/hw_random/amd-rng.c | 18 ++++++++++----- drivers/char/hw_random/geode-rng.c | 36 +++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 13 deletions(-) -- 2.20.1