Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1552466pxb; Thu, 4 Nov 2021 04:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQJz9r5lqk8tRUqFPZBp3IAEJufbW8sf/xPi5LJBfRbma1I9XrvLKM0UUayQN9aGg7rWlq X-Received: by 2002:a6b:4f07:: with SMTP id d7mr3052016iob.28.1636025532192; Thu, 04 Nov 2021 04:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636025532; cv=none; d=google.com; s=arc-20160816; b=VirFyQc0seIzLSANS7wNuIOpAkcKc4h7T3knIMG+d/niyf+fgsFW9pvrVtirJd84aD 64Ll5DE613TowmeHQtj5HyqmsPpVBO6lt+DsFLVXBE30W1qDdIV8h3ydRBkn7F00KYhd A3A7tlSeyKRIV/db8JEJdGVH+8HFvrLzcROKDKRWtudfomSsI5PBgprfTjyvRhCtwLug It4NC3yxIhG9gEicbzf1I2gxhay52Monvcu5b2Q5kEukNYqExM3gqK34lAz6WaBVjgaW pj6rD8VIBY5bph/vaU/AYT9QIc84vN6D3bH5eyxjn4yCGLb2dF0pDO8XJHPz0c+/Qwlx XFtg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=XI7srUscK+Y38/Rxj8sDNS7Olpg887NgDMGVmRQv+y8=; b=e8aja9inutniea2E0S89HXdmC92tOdGGywkXJDr/btrL6BdNJcTXgvI+lC3be5EbkQ IxOfTE8TYwhvGZ1S2iYtQeMGms6GTn9Ugdp36pSi7tklD10QFRq3k1V5m06OyIgLYtkL TLVCPKO/9vG3EkkznqPv9cH0lrWQaA+4aWIECi4EKLeFpiaam63icaH/5FwaXpfUozUp KnltDvnvjRYcltbAGp7lCBiAWrQvZ43Ok6T5+dHyXQzEhu9QQ1Ma+12SYdtyO3z9pqYH qabIIeqbThGZ7IyZG+CgMBaKMtqH5apXDWoV31IQBM0BTKq583uqFPy6mq6O+f1iPZe3 DuxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GTZx0G9t; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si6396568ilk.22.2021.11.04.04.31.59; Thu, 04 Nov 2021 04:32:12 -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=@gmail.com header.s=20210112 header.b=GTZx0G9t; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbhKDLdi (ORCPT + 99 others); Thu, 4 Nov 2021 07:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhKDLdh (ORCPT ); Thu, 4 Nov 2021 07:33:37 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B246C061714 for ; Thu, 4 Nov 2021 04:30:59 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id v2so4999105qve.11 for ; Thu, 04 Nov 2021 04:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XI7srUscK+Y38/Rxj8sDNS7Olpg887NgDMGVmRQv+y8=; b=GTZx0G9tMBm48ys0jclkhqpFjUgcGjpRl0HcyPh1VsfbXFPPio1IAUAqiubBcql+KP WzRDFR3KejSKCRPQNoiGq2nz2nSejbhBsf+eu71Qpjx/aHShLqJttKr4VDcsgF4dvRfC jUmuA9UqYCv91cj9x2l4Y1fPYvAk4SRfsDGbg9VoSIne4uus+i0h0HH8i5XNLgyb9xtU nXXkxcPp40iBEu6e1gVnugmGN36kru73bt69x1u/6zBCOcM+J3TBbSgHRzf1+98lEuaY +f4cNa+nZrbDf9p/juY/8xbdbDdmX3tTt17vNkMkff60UWZFk/+WJGF4PHzVs9IDfn30 vt+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XI7srUscK+Y38/Rxj8sDNS7Olpg887NgDMGVmRQv+y8=; b=O1HiH27W0VOtb9q0Q7quqwDup6SA/9eASjc8jd3/UFMyvZ/nEO/6MDYj1CzSGU0pb+ Kn6q1CuVqRDL+CiXHCULWKupUZBtvChSwzDCC+lRphkeM2f1u7YDIYEUMIemJjrO+9OI /A0r3PferyT5W1j+YO5hjXthMpf1WS5vZW0W8GjPchxx9x05/70MsJl1mVwSUHtMt0pv K1S0uQ+eG3HPQx/S16CJ6vd4C9+6gd53Z5pcXplic58pBXSXDFtwWSdAtBc9tlkWDZVz yfJyKdVrlirduuF+3i2sHfcAmVzsHOsM8jUvMh835dlz16V1a9inB3ncreTdhrorDefv fQIw== X-Gm-Message-State: AOAM530ChuTuy827PFqyXuS1ic25WYYlXeUPtGRp8erHqu/d3siEMgXW DpvkF6rH+VBq9zGOx8L7+66ajBnrA9U= X-Received: by 2002:a0c:9d05:: with SMTP id m5mr47454320qvf.30.1636025458621; Thu, 04 Nov 2021 04:30:58 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id o8sm3732206qtk.77.2021.11.04.04.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Nov 2021 04:30:58 -0700 (PDT) From: cgel.zte@gmail.com X-Google-Original-From: lv.ruyi@zte.com.cn To: jens.wiklander@linaro.org Cc: sumit.garg@linaro.org, op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, Lv Ruyi , Zeal Robot Subject: [PATCH] optee: fix kfree NULL pointer Date: Thu, 4 Nov 2021 11:30:47 +0000 Message-Id: <20211104113047.28585-1-lv.ruyi@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Ruyi This patch fixes the following Coccinelle error: drivers/tee/optee/ffa_abi.c: 877: ERROR optee is NULL but dereferenced. If memory allocation fails, optee is null pointer. the code will goto err and release optee. Reported-by: Zeal Robot Signed-off-by: Lv Ruyi --- drivers/tee/optee/ffa_abi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c index 6defd1ec982a..8d9d189557f9 100644 --- a/drivers/tee/optee/ffa_abi.c +++ b/drivers/tee/optee/ffa_abi.c @@ -811,8 +811,7 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) optee = kzalloc(sizeof(*optee), GFP_KERNEL); if (!optee) { - rc = -ENOMEM; - goto err; + return -ENOMEM; } optee->pool = optee_ffa_config_dyn_shm(); if (IS_ERR(optee->pool)) { -- 2.25.1