From patchwork Wed Feb 20 06:02:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158766 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4536400jaa; Tue, 19 Feb 2019 22:02:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ83YQsSrPlcM1G//g+3pEzs5KubGvKzu10LdZqN/jWmUa5ABs5nV8kbF+jxIrCNFbBp3Md X-Received: by 2002:a62:560f:: with SMTP id k15mr32935132pfb.231.1550642576237; Tue, 19 Feb 2019 22:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550642576; cv=none; d=google.com; s=arc-20160816; b=OQ1mgZo3f/bPWtmizi9Psn7TzJFdm36y5sKQ4jqKgHo8Gp6E2lieU1qg0GVZe15nQb 3D5+fGOSlnb8sRmEmxd5h9ufC2CWNnzjZkcyV4AeZz4sPNBa6rVeGw6LMPsUW7xmmld7 HsntnC3k3crhyWyOiTOsEI4TzFQHID8dCR4WfR//XBeXgEgaZpzjNhKWmjI7X49xylW6 PNiKaNZ2uKqcdvxXg8CJfAq9G41MFEBQP/0CqW2NZOpWmnHGG+NS01xg6c2WSFCzGSS6 UNFudIP2YMM7qRE3ayVvBtMQ9yqLQaLQ/LkD26T7IPOb4NLzFGsa1Z0Lyznzgqm5OYRK zuQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=d6A0igDOsc3jNLySuAErsWHOJjhNYwodP/Hd1Anf35E=; b=sZCwo8N258pzNbe/usWU7XaRX9DgEzm+BiDNQq+jzHOgyCTXhdI4kpdXU1cL8Y2bcK A5zJt7clMBaFgsJi22ZglaAugLQrhbE973foJZ0csL7DaKmOqlI/gBgymPbko1QR3IBh hJjB9sPI+4IHfyiQji4IdMYVVzzFoyp/tciwBqp7FUKguqRCumhn2tF6N4NEiJGiGv0K s2SJQcZG/ofVpxL0TF7BAmui2vLkhsYNn1/yeCWdDA+CZhnzDD8ep9dOk7sFLl/uT9ly v7tBq+WwxOx7RLIbhdeM3VCD+OXN49iiUqqiC3YSq7wBqTRTxC5oqnk+1iXqVxSxzjYq FKWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lCfZdzVf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8si18202526plb.10.2019.02.19.22.02.55; Tue, 19 Feb 2019 22:02:56 -0800 (PST) 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=@linaro.org header.s=google header.b=lCfZdzVf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbfBTGCy (ORCPT + 32 others); Wed, 20 Feb 2019 01:02:54 -0500 Received: from mail-pg1-f178.google.com ([209.85.215.178]:37779 "EHLO mail-pg1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbfBTGCy (ORCPT ); Wed, 20 Feb 2019 01:02:54 -0500 Received: by mail-pg1-f178.google.com with SMTP id q206so11318765pgq.4 for ; Tue, 19 Feb 2019 22:02:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=d6A0igDOsc3jNLySuAErsWHOJjhNYwodP/Hd1Anf35E=; b=lCfZdzVfUjOoBZ+L8AhBPSXnJxoCCXiZL2BEUhM0u/EDD5wRHimQtqgOVKdwAGdkAQ Q/oXwg6XKdb5HBpqN1JMFfKNQe3Aci1BcQO8YnMU+CDAnSNCTUyamtg7rPp/1wqvWbsI P0sW1zttfI77GPUv8JNKqWo6ssEN3oT8rGc+Px7yzx9311+98ohUXhTG0GSXvulA3B/g lRy4Vl7wfN6DdNoxzKljPaUgS3r7r2Zpyre01RJ7KAeNgfMXp+/zerRWN+knm+QbPHDJ uNLbESWIvEEsxf+c/la+zTkeLUQexa4kEL6gjivyE9Tj/wh7zQ4HEwT0XZ1W1Y29dwT6 wcVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=d6A0igDOsc3jNLySuAErsWHOJjhNYwodP/Hd1Anf35E=; b=Y/eeGKqndHtUZsooLVZzIPSLyCy1YjetN/Li+zh/hhAWvMz+H0yeeZSefAG+DmOHto 0zoWmRIREQYVntyVYG7PcJTCTE/fobHwrP+2qv85pL4BF4erQbqkI5tXI6+94N9KkEjv Stb9E+jXFqZGa3IG7jlpVdj+OTCASlpcv0tDNLI+4PXdGs63AxGALf1CtDaUi1Fj42iP 8XBtNORGoT9cxZ7bXyQH9rYPgMnIFn9iJ+mXVkIzdYxy6jKDzAAFDXiPi2GtdUJGCYnX J/0OELGsvZfj+ln5TKGb6Qcyvt7v1awY0jcaV/49tAFtIoGPAnL6D95Ec0/2u6/79tjk Bwlw== X-Gm-Message-State: AHQUAuYr7dvKb3XW4bE0F+9UP2JfF7PwxmVNPhDVQjBqVd2i2PJKt8y+ XjH+R/5iFQRIunUpSf3SCps4R2c3et8KHA== X-Received: by 2002:a63:5b1c:: with SMTP id p28mr27045620pgb.73.1550642573331; Tue, 19 Feb 2019 22:02:53 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id z1sm27945835pfi.155.2019.02.19.22.02.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 22:02:52 -0800 (PST) From: Sumit Garg To: jens.wiklander@linaro.org Cc: dan.carpenter@oracle.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH -next] tee: fix possible error pointer ctx dereferencing Date: Wed, 20 Feb 2019 11:32:27 +0530 Message-Id: <1550642547-21968-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add check for valid ctx pointer and then only dereference ctx to configure supp_nowait flag. Fixes: 42bf4152d8a7 ("tee: add supp_nowait flag in tee_context struct") Reported-by: Dan Carpenter Signed-off-by: Sumit Garg --- drivers/tee/tee_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 25f3b9c..06fbfc0 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -993,7 +993,9 @@ tee_client_open_context(struct tee_context *start, * tee_client_open_session() if any in kernel client requires * different behaviour. */ - ctx->supp_nowait = true; + if (!IS_ERR(ctx)) + ctx->supp_nowait = true; + return ctx; } EXPORT_SYMBOL_GPL(tee_client_open_context);