mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nelson, Shannon" <shannon.nelson@amd.com>
To: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>,
	brett.creeley@amd.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
Date: Tue, 24 Oct 2023 13:58:00 -0700	[thread overview]
Message-ID: <c50f2d3d-98dd-4194-9080-81298dd0563c@amd.com> (raw)
In-Reply-To: <20231024182051.48513-1-bragathemanick0908@gmail.com>

On 10/24/2023 11:20 AM, Bragatheswaran Manickavel wrote:
> 
> 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: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>

Thanks -sln

Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>


> ---
>   drivers/net/ethernet/amd/pds_core/core.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
> index 2a8643e167e1..0d2091e9eb28 100644
> --- a/drivers/net/ethernet/amd/pds_core/core.c
> +++ b/drivers/net/ethernet/amd/pds_core/core.c
> @@ -152,11 +152,8 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)
>                  dma_free_coherent(dev, qcq->cq_size,
>                                    qcq->cq_base, qcq->cq_base_pa);
> 
> -       if (qcq->cq.info)
> -               vfree(qcq->cq.info);
> -
> -       if (qcq->q.info)
> -               vfree(qcq->q.info);
> +       vfree(qcq->cq.info);
> +       vfree(qcq->q.info);
> 
>          memset(qcq, 0, sizeof(*qcq));
>   }
> --
> 2.34.1
> 

  reply	other threads:[~2023-10-24 20:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 18:20 Bragatheswaran Manickavel
2023-10-24 20:58 ` Nelson, Shannon [this message]
2023-10-25  9:22 ` Wojciech Drewek
2023-10-25 11:39   ` Bragatheswaran Manickavel
2023-10-25  9:40 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c50f2d3d-98dd-4194-9080-81298dd0563c@amd.com \
    --to=shannon.nelson@amd.com \
    --cc=bragathemanick0908@gmail.com \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®