From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1044840AbdDWKXm (ORCPT ); Sun, 23 Apr 2017 06:23:42 -0400 Received: from m50-133.163.com ([123.125.50.133]:41114 "EHLO m50-133.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932520AbdDWKXe (ORCPT ); Sun, 23 Apr 2017 06:23:34 -0400 From: Pan Bian To: Joerg Roedel , iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] iommu/amd: fix incorrect error handling Date: Sun, 23 Apr 2017 18:23:21 +0800 Message-Id: <1492943001-1078-1-git-send-email-bianpan201602@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DdGowAAHhSKZgPxYcKUhAA--.630S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF1DCFW3Zw1fZr1rKry8Krg_yoWfWwcEq3 y8XFZ7ArZYkrZ7C3WjyF42v3sYgan8Zrn3ur90gw13AryI9rWkCa4kZrn7XrW2gw4I9asr tr9Yg3WSvry7XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUngTmDUUUUU== X-Originating-IP: [123.118.194.153] X-CM-SenderInfo: held01tdqsiiqwqsqiywtou0bp/xtbBXhvC4FaDqPbKywAAst Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pan Bian In function amd_iommu_bind_pasid(), the control flow jumps to label out_free when pasid_state->mm and mm is NULL. And mmput(mm) is called. In function mmput(mm), mm is referenced without validation. This will result in a NULL dereference bug. This patch fixes the bug. Signed-off-by: Pan Bian --- drivers/iommu/amd_iommu_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 0633439..6629c47 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -696,9 +696,9 @@ int amd_iommu_bind_pasid(struct pci_dev *pdev, int pasid, out_unregister: mmu_notifier_unregister(&pasid_state->mn, mm); + mmput(mm); out_free: - mmput(mm); free_pasid_state(pasid_state); out: -- 1.9.1