Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3480805rwl; Tue, 27 Dec 2022 09:44:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXuT71vszNj/N4BvWA6u6TdGG94YlIOjKNkmQ66xsJb8pEk+pIC3g6Qr2tpWKvYwSadZw8sv X-Received: by 2002:a17:902:8d93:b0:192:6990:ba60 with SMTP id v19-20020a1709028d9300b001926990ba60mr11371334plo.63.1672163064332; Tue, 27 Dec 2022 09:44:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672163064; cv=none; d=google.com; s=arc-20160816; b=iVgnqS37/cZhrQq1uVfFEpwPo48hkUxOCEPXUvAd89xIa3qddz517ia8cXU49xxhWi awfW9rWzyQ4si9lPB4TomUfHr37rb37G0qbAL/c1AHyx9VMH/QeYCH2B228+nZk1Rg3S 7FopGspOqTGi6MZqGHDizELd5ZcTOFd82VzhHQTpqGYP5zIkEGsRhH2A8KKUXtJ9S48L S32tRn7QxY0TZ/KcHBAslZpwbVIfwCnSKYY6gqTRYchJHHzgMNJAZY625wOI8zAPnYtZ 1kC+tIuJoL1aEwk38k+N2kk5N2LU8gRtxHmqfX1E8b6BlxJ5UD0c3sWXWzIfNm6iMAdQ FnPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=mXDq2twm7AMJjSe3SF3E0znzKISr4JsiPRRtCic8muY=; b=CMpBNB7B3Q1AzzvZHr4oYeBi73zvxWn/jluKGlAHeFwjm9AkpWvketu/4rCat75nGd XFdrzBMrhrcZbRQ87RjnVgBqH+vDB/GCn138rjZos40TRuHsgRJYnf/ZvetNYjbjpcDb AZGF4mjVctr5oFkB+1P6rA8nkp+zA1EFY31gv8FneNn4O33wHP3r9eTLQOHxPkSHiFZw rL20hy4N+Hp2Kls/GpHWuTIJRgSmeUtV4V0NfSKuwYwKnleR/0vD8fIY7kQtZNDWY2+D I93WaF5C8pN4+/ny6mbi926sMkqRJl1UVlXzbtMWpVxskkLx8AWG+3ArWHqfD52Mc2Fk RttQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=PFvbFEkO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020a170902d58300b001927aa58c73si5574311plh.203.2022.12.27.09.44.15; Tue, 27 Dec 2022 09:44:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=PFvbFEkO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbiL0ROp (ORCPT + 66 others); Tue, 27 Dec 2022 12:14:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbiL0ROh (ORCPT ); Tue, 27 Dec 2022 12:14:37 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86A4BF7F; Tue, 27 Dec 2022 09:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1672161267; bh=t7PT2uktgkerHfBW8tbhYinlf/iWYlEafzcWDES++jM=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=PFvbFEkOjToKt4pNFDu81BSQhHuNoyMGKRRB1qLS/ma35bUMEGFGb4WWuIzm+JJs9 /KBGjbdAWvKBrsl3hbI1VMkzh1m1q+B3NyPN3EnwTckyAp7FEHxf/2DsKzWa0yKogr xUhVjDhHGShJfc1i/8vvL0xMSqkEAQYpGRcPYHvE= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 27 Dec 2022 18:14:27 +0100 (CET) X-EA-Auth: kTiepSjWpyi9Ji8iWRK5eWeMrKdUoRK+JaiTVgN5jm3nna2m7biYtAmN9vNNkbmNg67H6j5YGy8WqhY1z1C7Uqq/5buDi/8h Date: Tue, 27 Dec 2022 22:44:21 +0530 From: Deepak R Varma To: Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] drm/tegra: submit: No need for Null pointer check before kfree Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kfree() & vfree() internally perform NULL check on the pointer handed to it and take no action if it indeed is NULL. Hence there is no need for a pre-check of the memory pointer before handing it to kfree()/vfree(). Issue reported by ifnullfree.cocci Coccinelle semantic patch script. Signed-off-by: Deepak R Varma --- drivers/gpu/drm/tegra/submit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c index 066f88564169..06f836db99d0 100644 --- a/drivers/gpu/drm/tegra/submit.c +++ b/drivers/gpu/drm/tegra/submit.c @@ -680,8 +680,8 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, kfree(job_data->used_mappings); } - if (job_data) - kfree(job_data); + kfree(job_data); + put_bo: gather_bo_put(&bo->base); unlock: -- 2.34.1