Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2304940imm; Mon, 28 May 2018 05:45:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqQUKAnRwJ06BPzziBMHAz5bNF1hxgIZzqgTqHcBcfShK4tz7VqdRH/LeYRiqgMbj+Ft1wS X-Received: by 2002:a62:190f:: with SMTP id 15-v6mr13377413pfz.42.1527511542423; Mon, 28 May 2018 05:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511542; cv=none; d=google.com; s=arc-20160816; b=jI8O/DEQnjWZyCRt2xKmjYLi3vEAgzIrbbqSo48kltj3f69ZFAm1vd6cIVziIxURPp R/dYi/Qi3iaRsOuICO7jCqPM+UF0DqirfCB1Zt9WcEQKl+Me3gGVOYcj56dUj63DNle+ JJnpo50RDxaCinir/eFlmKH7zHMBHAKPbHJPWozmNQ/AOx5tijNu85tFnOt+x0NqNFeY K0Y/oUTqJXVh7AxkQAQhvcS8U8nEtb/tcimRd9pezzwlCuWSTZ1UwAKqoyqTCkEV/TxR nXF5jJ1RrOdhLSqJHe1SIiQwWvXCWmwvqkS5M1W6ad0u/274qs1+eYKSHu0CmE6umq5a VMhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=hrUBcvvIQBc8SuPy4qbaiEYUsFG7GG42+xVdv6R9dMo=; b=fJ/bnyagLq7VFnhNaSv45lDjC/m0Nn1VfM9Z5O4glx/8/zcMfNr2GLAxoYPpmrZG/2 WQla/0RqdUOaWK8p2s6wB8uYYTRUgfvsCoWAugh47JjOO0DvTJyKxRyT1PFt3xuArd2J Ynm97VUbdEyHGjfPf8SmHKp2ucZHT4JidDCeV7Q1pGZ3gOUIg6rwJ5/kU0Gfrh7bbPfw 46zistiuz31mGuxRV9uM/A6+7wN2eejG0dA/Pj3Z+9+syLSjQcUM6Oc9k8WlOqpE1e9t +HxQME8oL4r6Df6RHiSo1XnL90oHndTUfzNsByHhpCfMGvVWqTO62cgyNlzbdKwaVP5u /4Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X9GQy/rF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21-v6si7082222plq.94.2018.05.28.05.45.28; Mon, 28 May 2018 05:45:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X9GQy/rF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938914AbeE1Mnn (ORCPT + 99 others); Mon, 28 May 2018 08:43:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:46028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932332AbeE1K5u (ORCPT ); Mon, 28 May 2018 06:57:50 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED733208A4; Mon, 28 May 2018 10:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505069; bh=4w62cKzkg/WT3yzJg72ktuZpAldDs0Qwod1Q3ocfCEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9GQy/rF8495ykYxXpbhaHxqim1wvuyrEt1zgHK/APgHlFzRkcjpP9lNn5CDtZlNA pAQoMZ5kjDxL13ejKZvBNJkbGA371ksle2R/USSsPMrssti6WVJkA9SRUVYI4Jgg/2 LgCXMov2FPXCbYWW4yVLfs1nNEwkh4VgBU9VBri8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baoquan He , Sebastian Andrzej Siewior , Joerg Roedel , Sasha Levin Subject: [PATCH 4.14 365/496] iommu/amd: Take into account that alloc_dev_data() may return NULL Date: Mon, 28 May 2018 12:02:30 +0200 Message-Id: <20180528100335.175960810@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Andrzej Siewior [ Upstream commit 39ffe39545cd5cb5b8cee9f0469165cf24dc62c2 ] find_dev_data() does not check whether the return value alloc_dev_data() is NULL. This was okay once because the pointer was returned once as-is. Since commit df3f7a6e8e85 ("iommu/amd: Use is_attach_deferred call-back") the pointer may be used within find_dev_data() so a NULL check is required. Cc: Baoquan He Fixes: df3f7a6e8e85 ("iommu/amd: Use is_attach_deferred call-back") Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/amd_iommu.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -311,6 +311,8 @@ static struct iommu_dev_data *find_dev_d if (dev_data == NULL) { dev_data = alloc_dev_data(devid); + if (!dev_data) + return NULL; if (translation_pre_enabled(iommu)) dev_data->defer_attach = true;