Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3622175pxb; Mon, 24 Jan 2022 13:43:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoCdYCXGfDE4rmG0EojRGfdAp1/F3n5A5xRFzObTNB4cka9GIo1MpETSLmx3e9UgEfSGy6 X-Received: by 2002:a17:90b:314e:: with SMTP id ip14mr186206pjb.213.1643060626816; Mon, 24 Jan 2022 13:43:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060626; cv=none; d=google.com; s=arc-20160816; b=hKD+cJh4DFCA4mFxkSJPa8rz/tq6eE05Tpc64zz6TjUoJp5WOP3y6Hm6Jsq99KK+LC GTst6GUplLct+V4Or6M3v4bHGhRHWX9lzmpYGsxlP85wcx0otoeTkL0K6NT/g5erXi/w fRDBD832BZuUhO8jBpSQ+IzDwULZGPFswIzrZpT7TUpanOMKkR+DcSQp2U+OMLesbHK8 hBTQ+LigPyQym+pV5fmNNjPPdw0iX6qqdekO2XpDBf9eALMVXM+k1V5a9/tjKL5jpNhY H7VJzQoYo5xPWSUwp9NI92Kw1tnc+Fiz9UfZGGDwFU/nk7SsPl1ZS1y/uBsyTAEHl0Xf LR6A== 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=E2mA2cXWW9K+t44Flunb0W1V+hgEaMAt6WyhvXNE28Y=; b=HXe6knDN3geowZyAqn7mzW/3SnQmhOwoQL0deIFPvlg+ryKDzl3YQ20YXKBCKDjvUp sVy8ji9iNCiP2611q5UDz8+kyi2+kpq1sr8T0XbydFNGl+nbte75geCQhh+keWhKyQgo pL2xGwYlK3TlxfNZOxRqEdcDWqkkCM8PCtl3R9JxFSukM17wdSPwErVKgISD1WG6DK9/ 1niNdNGFz6XDSn5kJQs3p30xhK9Y3Gk9FtiL2pVbn7JTA/WPGVxEagJfL0UKb/6/4iQZ vj0x3UVSb66625nBVLJB+zfGIwt3DGaZSqwnXDuzIoCXgINn9Qf9R94p/fJDFHjlu0Ea 9Tkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ugAdMgex; 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 a9si14474779pgj.262.2022.01.24.13.43.26; Mon, 24 Jan 2022 13:43:46 -0800 (PST) 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=ugAdMgex; 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 S1452074AbiAXVYA (ORCPT + 99 others); Mon, 24 Jan 2022 16:24:00 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49848 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443443AbiAXU46 (ORCPT ); Mon, 24 Jan 2022 15:56:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D748D60B03; Mon, 24 Jan 2022 20:56:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8774C340E5; Mon, 24 Jan 2022 20:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057816; bh=e4BpGwdT8izfHTQPZn1Ny6wEvrlLCnwgZUVm5AB7R5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ugAdMgexZTUNmSKUvataG+vr+3PS14HBp4AdKRH8VLr3FVUuGoalUfu6bNwIQ7r2i JV9S2famDY4u29QcLDGfa1IQrdWPXCkitW8nmv+nBgTjOINT0LPCJVWKZJRoO8HT4C IWLHUt7NZvYqAo+d+XSiizvVDvlJCZ+ExnibPlvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emmanuel Grumbach , Tomas Winkler , Alexander Usyskin Subject: [PATCH 5.16 0056/1039] mei: hbm: fix client dma reply status Date: Mon, 24 Jan 2022 19:30:45 +0100 Message-Id: <20220124184127.033162199@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Alexander Usyskin commit 6b0b80ac103b2a40c72a47c301745fd1f4ef4697 upstream. Don't blindly copy status value received from the firmware into internal client status field, It may be positive and ERR_PTR(ret) will translate it into an invalid address and the caller will crash. Put the error code into the client status on failure. Fixes: 369aea845951 ("mei: implement client dma setup.") Cc: # v5.11+ Reported-by: Emmanuel Grumbach Tested-by: : Emmanuel Grumbach Acked-by: Tomas Winkler Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler Link: https://lore.kernel.org/r/20211228082047.378115-1-tomas.winkler@intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/misc/mei/hbm.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c @@ -672,10 +672,14 @@ static void mei_hbm_cl_dma_map_res(struc if (!cl) return; - dev_dbg(dev->dev, "cl dma map result = %d\n", res->status); - cl->status = res->status; - if (!cl->status) + if (res->status) { + dev_err(dev->dev, "cl dma map failed %d\n", res->status); + cl->status = -EFAULT; + } else { + dev_dbg(dev->dev, "cl dma map succeeded\n"); cl->dma_mapped = 1; + cl->status = 0; + } wake_up(&cl->wait); } @@ -698,10 +702,14 @@ static void mei_hbm_cl_dma_unmap_res(str if (!cl) return; - dev_dbg(dev->dev, "cl dma unmap result = %d\n", res->status); - cl->status = res->status; - if (!cl->status) + if (res->status) { + dev_err(dev->dev, "cl dma unmap failed %d\n", res->status); + cl->status = -EFAULT; + } else { + dev_dbg(dev->dev, "cl dma unmap succeeded\n"); cl->dma_mapped = 0; + cl->status = 0; + } wake_up(&cl->wait); }