Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3600457pxb; Mon, 24 Jan 2022 13:13:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJw47vMSd63yizyrFLVCA7MLaKzuOZPHOpOwgZeZbOol1NWTudR63NzX3yHngTwjs+hS5xLh X-Received: by 2002:a05:6a00:21c2:b0:4bc:fb2d:4b6f with SMTP id t2-20020a056a0021c200b004bcfb2d4b6fmr15368594pfj.62.1643058827503; Mon, 24 Jan 2022 13:13:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058827; cv=none; d=google.com; s=arc-20160816; b=vWXGjRaVOVZQNGAy0i2gHILM5JuSKZce5pb3enzoVPqFFvLNKhEBG09x1uMx1SvLmI zPwYxZ5PTGkPP9boaIrhSjUubH0bRBRjJ6zvhH+GhqZGA8m2Ji2c7WyVaTZfAy6tX8jv RxDB0AwLLYmC+tJOyhZqWxg8lfTsnbDKkEmXmInyALF6ga+O1FVcskzBmzGh0vRlxYED +7jPgppGZ5FP3ob3lDG5ThBgCs0CPsLNzkeavcgoSw+z6IHok3beCRczc5Esl79d7yb4 NiNzeAfnwkZ5aGC7NRHdAIXa1iWl2BVhmmrziu8SY1BQXMqX6o3SwE/kaROMpTZiPBXX cT5g== 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=SxvWnluRkhWcZgHb6wgEC0QRFmFV4jrIiSkGfsLb1yF7A/zKYP5To6XYV8z1pnLeUZ izqjipwLyet/tgJvVZ1hDWbadQ5A/UJtCNhw+d07ETjPLxNVJvLcltK8cK5AxcBL+6fa KnVB8QiVFxT/B+oLEKPylnFtyGCi+MKupmBe+DFJ+CE7ceHmmG9PIkyzswEBYlYIdsUp pQM0di3M0gbfI/vQx8M1QSmoqQW4Uv8mp4dZuSv6BG8vyOSJD3blX7hg9hVD7etky3Ah aplxYLyQt0S3PB/DCB9Pfw4XuFazJa6dV7J7fUyeQUcXtvCCrxdLlyNLAhV/MhT/7NSN 4xKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z5hpAObu; 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 j191si10423499pge.528.2022.01.24.13.13.32; Mon, 24 Jan 2022 13:13:47 -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=z5hpAObu; 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 S1387673AbiAXUhB (ORCPT + 99 others); Mon, 24 Jan 2022 15:37:01 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:39360 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347091AbiAXUMW (ORCPT ); Mon, 24 Jan 2022 15:12:22 -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 2D3CD60B89; Mon, 24 Jan 2022 20:12:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 043EEC340E5; Mon, 24 Jan 2022 20:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055138; bh=e4BpGwdT8izfHTQPZn1Ny6wEvrlLCnwgZUVm5AB7R5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z5hpAObuaB5DXsP87yenYC4+R/bmM4KONpqdNyUKbUKm/MEdQ/q5MO1/4rEul29Ud dnpxqAS/fVRe07P3ys+uyLoz7Y7UXop/xyVuQAjrxObcxZ1z5qGWrfmv3EvdDMckqu WSrQbzZ6KM+raZg6+kgItBjS8SfJXKay6vwgN9f0= 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.15 054/846] mei: hbm: fix client dma reply status Date: Mon, 24 Jan 2022 19:32:51 +0100 Message-Id: <20220124184102.828509019@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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); }