From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C16BC433F5 for ; Mon, 8 Nov 2021 05:38:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E79316120A for ; Mon, 8 Nov 2021 05:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236938AbhKHFgw (ORCPT ); Mon, 8 Nov 2021 00:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbhKHFgu (ORCPT ); Mon, 8 Nov 2021 00:36:50 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47100C061570 for ; Sun, 7 Nov 2021 21:34:06 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id o18so33391536lfu.13 for ; Sun, 07 Nov 2021 21:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gpm7jPZ0ZMPW4LY+8KRKOKkVEUHfPW7d23ZeDD6AHnM=; b=clg5vcEitEheMZx8mbDe7QnU97lNI4yoQQENZvJmRRtm1abIdfZ6gJXGV0pelj+b0U dcpWZsOFazA1IGlq7SrDphfBwQnvrCHrVGnpBWH5cDVlShVMg39NGVxzHDMBVJDURIdZ r45zV77psix8kpU5aRuHMFOO7DCOGXkHYh8E2cmRfxwLJ7RlgFGuZdaVI/9t9AEC00wP f2nv6IZ3vMiNVFFpATlVwi+xNcWZfpwdwEoQ1SBmzUZGlG5TN8h57FHiFJ8hj13X/SKm fgnRFWgwF58d3NWjdW5QVT1Yk5aCfV9tIJbG5SoWfDDcxv00aQJUeKZ0FDWWi9zMnsta RN7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gpm7jPZ0ZMPW4LY+8KRKOKkVEUHfPW7d23ZeDD6AHnM=; b=Gah2cqqMPyOfai0RKP+eVLAXpeDA8SXPcZkwhu3cczmu+FxUg3HoLK4XKwrwH6QKTk jxQJmV/3WxqlESY8CLYm99vhvMeh2z0omltQTmqL/N063Lpf9XgfT/rvO4f3ymSCCGT4 xIEg9qX+RuJnuBtOFd8VKb8LdGMHqsYk5qjSDTLfFjj0ywb5YtG1PLA61QWlkf2OnBGh RcIVkk08+wfouD0Rh7kVdYdkFYRL4Kb8meklTiuLwgR/li6/eI48CsdYawt9fMhQNftT A7EWXxH/2gVqVDZb9w1F+8aZK/Cwe3utP4eMGB3+zPDiKbGGidFImJgmChKl2OOdrq4q +P2g== X-Gm-Message-State: AOAM530ZeX0MTYtnom6mpBfwXG8y/KJlYT6AU7ngUPo4SQ+xiiHQ4eIS osQYlgC+7qQ0xjClvGLqU2te/8lu0YiZ0uSF9A3cjA== X-Google-Smtp-Source: ABdhPJwgdGJyUpyR/mOLSV0b8Ig0zVB84wH3mLDwnfuV+O4nI7wKaMy5cn8BFLLuoLCj3znUKkmkfobNqIPVlpDJh20= X-Received: by 2002:a05:6512:2291:: with SMTP id f17mr71245439lfu.253.1636349644569; Sun, 07 Nov 2021 21:34:04 -0800 (PST) MIME-Version: 1.0 References: <20211104113047.28585-1-lv.ruyi@zte.com.cn> In-Reply-To: <20211104113047.28585-1-lv.ruyi@zte.com.cn> From: Sumit Garg Date: Mon, 8 Nov 2021 11:03:53 +0530 Message-ID: Subject: Re: [PATCH] optee: fix kfree NULL pointer To: cgel.zte@gmail.com Cc: jens.wiklander@linaro.org, op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, Lv Ruyi , Zeal Robot Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Nov 2021 at 17:00, wrote: > > 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; > } So the braces are redundant after this change, hence can be dropped. With that addressed: Reviewed-by: Sumit Garg -Sumit > optee->pool = optee_ffa_config_dyn_shm(); > if (IS_ERR(optee->pool)) { > -- > 2.25.1 >