Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3038819pxj; Mon, 17 May 2021 16:11:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFTIszirJPgpH/g9nRiWgIG2ngnhaJPMSj66V2Cca9V/ZQtcCQ6pB451t1fe3wpiqTeb7h X-Received: by 2002:a05:6638:22b4:: with SMTP id z20mr1974037jas.128.1621293108094; Mon, 17 May 2021 16:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621293108; cv=none; d=google.com; s=arc-20160816; b=RjT/Qdhq/cFC1k4cIyBbDh00Nh2zn6JMoM6IW8tOAsi92QGIVMa/g8Mu2wvk5gWEQR K2yokM/GOgu44pMEFY6tdS15W4j3yW2sEFSXNrV4cOkIqCX7fI1VtpSuuUe4958D3mFa 7jIV/20sRZB5M9x3advp/c5ZOm3LYkN9JPScyMV4pImb1aKykEJWrX0imez5dIHgDByn rxMONRem8M/Ccy2N4ccZQioYiLEKQV6NJQVk/cEWmDryDQbcEsHvToQcASO1AowfECYw +fsX8mtNwBCDH2JpzmzJnmfxZMO0xK1WhlzLpJWlF3kG3PbBjlUlC6+1rsMAhPZSQyyS 1Flg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=idEMfZCo0xK+0bqrMddCTyJrzBA8hNdUFQpZjE/Z0XY=; b=steE2R9r3nYdGEJhwBF7uLpVRQsQS207lbJepP5C2qq2OGvrIQ9OdvBnLNXA5xd4CU GgFdtSLpd7FElrrlJsX8UDMIpKPSEBiZ3+j+nVptUUofNvHoA7qr6S+QCBxgPmuBKe5b n17o9jBpSugPDvgjXYQctDo/SkQpsuuicrSFiQ/E+GzVfm3+yO6qf/wJ8kuPMZcsddjp 3Xx21zHoW5zlBfn7CnjlXpV22Pevf7PC/8soQcWfc6FWumQkYoFbJt3qG3PKoktzgQI2 Jgl/F3b4CourvjDnaPuqkeyxbFAjEywyV8hJDVWcm0T9PUMjjXNeHXpJG3ydnSAAmekt o6Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jFYoWgi6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si17736689ioj.71.2021.05.17.16.11.34; Mon, 17 May 2021 16:11:48 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jFYoWgi6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239191AbhEQOWR (ORCPT + 99 others); Mon, 17 May 2021 10:22:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:35964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239136AbhEQOSt (ORCPT ); Mon, 17 May 2021 10:18:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30D5F61411; Mon, 17 May 2021 14:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260631; bh=6sevLBjQRawxKCUul0smE+K6rL/V3rBWtnuTo9KgPbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFYoWgi6ICkfgQlZFskpf0aofK3ML52aDDTz3TgaxGqr1gkIY5B0Yf4TjFvLPy3+a qkvbFsO5KaoMVLMnGbzx/prhlOxkAtZg9Yjs0T6o23zdr+gQdPcfaEekymz+rUdUaJ GJjnly3tgQXfX+N1qlNNVL/h1OeWiVL0khD7Z6qc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Dave Jiang , Vinod Koul , Sasha Levin Subject: [PATCH 5.12 168/363] dmaengine: idxd: Fix potential null dereference on pointer status Date: Mon, 17 May 2021 16:00:34 +0200 Message-Id: <20210517140308.283912407@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 28ac8e03c43dfc6a703aa420d18222540b801120 ] There are calls to idxd_cmd_exec that pass a null status pointer however a recent commit has added an assignment to *status that can end up with a null pointer dereference. The function expects a null status pointer sometimes as there is a later assignment to *status where status is first null checked. Fix the issue by null checking status before making the assignment. Addresses-Coverity: ("Explicit null dereferenced") Fixes: 89e3becd8f82 ("dmaengine: idxd: check device state before issue command") Signed-off-by: Colin Ian King Acked-by: Dave Jiang Link: https://lore.kernel.org/r/20210415110654.1941580-1-colin.king@canonical.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/idxd/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c index 31c819544a22..78d2dc5e9bd8 100644 --- a/drivers/dma/idxd/device.c +++ b/drivers/dma/idxd/device.c @@ -451,7 +451,8 @@ static void idxd_cmd_exec(struct idxd_device *idxd, int cmd_code, u32 operand, if (idxd_device_is_halted(idxd)) { dev_warn(&idxd->pdev->dev, "Device is HALTED!\n"); - *status = IDXD_CMDSTS_HW_ERR; + if (status) + *status = IDXD_CMDSTS_HW_ERR; return; } -- 2.30.2