Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp379772pxb; Wed, 13 Apr 2022 03:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHeYpdWwU2fyd3FAhH23lrI7N6VXLGtAtzC4ASUa6Bk+JEBwVVLOStq7hOHG/AvJTQrN+n X-Received: by 2002:a50:d711:0:b0:410:a51a:77c5 with SMTP id t17-20020a50d711000000b00410a51a77c5mr42399875edi.154.1649845341600; Wed, 13 Apr 2022 03:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649845341; cv=none; d=google.com; s=arc-20160816; b=DcgY6+kWFH8bDvWzZtu6j/SDXdg0FaJEYedUprcSszVlct2v70/Nzso2Yh9iUEtQmZ m9fz2LGayYhmVpS05TUAMhSOJzUrBJz2Xd0d/ly3PU1aMaoKMmqihps4UbhKxF4JGezl wLh0u4FOw8edx/eE0ZYXj5XQODD9OW4eJOlPKQibJjXQTxJs5lmvqzKen0uCw4f80UEo voNL/3xidaS6ohAETXv0OT7042SepsvBmKrJObHCuowZjME7jScc8ObBNxXgWWCo7yFQ CYWtmjc3CCN7vDPLsqAe1TqxXEMSRCcIQx2AFinGbYGIm8LwNb9DdTBpaHFVTcH5fMw3 XnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=5u/yJFbxRgW2t+B3rx9C6wEYQQxVaCgfZ+ICC6Wpw7E=; b=jSht6junpzjEKBr8uH9yoyyF3AMJqyhhOoFOqSgK3k9dEpjsbcwB2C+VYZyE2StMBm ukVLpDMa7U0339LUkMWaungaQsLM0ezEamFSWVIucu4fPy0Ggd38hmKKQMgTKrN8MQ13 Q6qrOF6eXfnlcC52pPSRVyzHCH0hMBTurhhT3ZHyWeWHEyu84YaZIRIz5slqKwiyrEbj jR28DlL0HhbuNMLpRW/X+rUJSCnRxLfGKrMEllMAGJ4BuZ5RG583MW3D5+S4eIGkyK1s 1cc5gi9QHZ+1yCEmzzCa/ydqowfcaV+roCpbLfNM/yVP4Temk6DU6yMLFlCexCOMLYrV UuDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=F1JGwIlA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq27-20020a1709073f1b00b006e89ef44c42si6620536ejc.366.2022.04.13.03.21.55; Wed, 13 Apr 2022 03:22:21 -0700 (PDT) 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=@kapsi.fi header.s=20161220 header.b=F1JGwIlA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbiDMHYu (ORCPT + 99 others); Wed, 13 Apr 2022 03:24:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbiDMHYn (ORCPT ); Wed, 13 Apr 2022 03:24:43 -0400 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E21614BFC4; Wed, 13 Apr 2022 00:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5u/yJFbxRgW2t+B3rx9C6wEYQQxVaCgfZ+ICC6Wpw7E=; b=F1JGwIlAUcDS//hyyFKjW7a6oE ARlYyQI3b9lAthrqyVgcEO/nk/zZNj+f/qgifQHe6Q7DfOdBI0NFygwfHo2jByyqYIfXn6KRSy5Vr b6uV8Rhf3MEtq8D7FpDJ5ZW8EVgizdUCTp7vM8TCjnyrDNJcoYbVJYo6VepK6oBrrVCGfokQahrkT 1CAfQVQcO7h3r8IOiVm8lf37UsxZTpnqjDZSlAUh4zI57klIahz0ucgu8+eJ6hamXnuv+90JmWFgZ hl1oNcv/KJyHp5Ix9Yfu4JwoghGpVmO42PWiRfloNFGfef2zTB2cFV67uwD32wAt46C0VYhMhHkXj eXpE95YA==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=[192.168.1.10]) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1neXKL-00083b-5h; Wed, 13 Apr 2022 10:22:09 +0300 Message-ID: Date: Wed, 13 Apr 2022 10:22:08 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: [PATCH] drm/tegra: remove useless if check before kfree Content-Language: en-US To: Bernard Zhao , Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bernard@vivo.com References: <20220413064618.23974-1-zhaojunkui2008@126.com> From: Mikko Perttunen In-Reply-To: <20220413064618.23974-1-zhaojunkui2008@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 4/13/22 09:46, Bernard Zhao wrote: > This patch remove useless if check before kfree. > > Signed-off-by: Bernard Zhao > --- > drivers/gpu/drm/tegra/submit.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c > index 6d6dd8c35475..54ac31bc80f6 100644 > --- a/drivers/gpu/drm/tegra/submit.c > +++ b/drivers/gpu/drm/tegra/submit.c > @@ -639,8 +639,7 @@ 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: (Same comment as for other patch.) I personally dislike leaving the NULL checks off with calls to kfree. With the NULL check there, while reading the code it is obvious that the intention is that the value can be either a valid pointer or NULL. IMHO with C's type system/conventions we need this kind of contextual information to understand the code easily and avoid bugs. Mikko