netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Yihao Han <hanyihao@vivo.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: kernel@vivo.com
Subject: Re: [PATCH] net: ethernet: enetc: Add missing put_device() call
Date: Tue, 19 Apr 2022 10:22:34 +0200	[thread overview]
Message-ID: <daf868a94da8ce7e4ee7e304db54cfee71b0174a.camel@redhat.com> (raw)
In-Reply-To: <20220415133633.87127-1-hanyihao@vivo.com>

On Fri, 2022-04-15 at 06:36 -0700, Yihao Han wrote:
> A coccicheck run provided information like the following.
> 
> drivers/net/ethernet/freescale/enetc/enetc_pf.c:1180:1-7:
> ERROR: missing put_device; call of_find_device_by_node
> on line 1174, but without a corresponding object release
> within this function.
> 
> Generated by: scripts/coccinelle/free/put_device.cocci
> 
> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
>  drivers/net/ethernet/freescale/enetc/enetc_pf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> index a0c75c717073..d6e18afda69a 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> @@ -1177,6 +1177,7 @@ static int enetc_pf_register_with_ierb(struct pci_dev *pdev)
>  	if (!ierb_pdev)
>  		return -EPROBE_DEFER;
>  
> +	put_device(ierb_pdev);

put_device() gets a 'struct device' argument, e.g. ierb_pdev->dev.

Have a look at the patchwork checks they catch this sort of issue.

>  	return enetc_ierb_register_pf(ierb_pdev, pdev);

enetc_ierb_register_pf() uses/dereference ierb_pdev, you need to
release the device reference after the above call, or you may hit UaF,
I guess.

Thanks,

Paolo


      reply	other threads:[~2022-04-19  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-15 13:36 [PATCH] net: ethernet: enetc: Add missing put_device() call Yihao Han
2022-04-19  8:22 ` Paolo Abeni [this message]

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=daf868a94da8ce7e4ee7e304db54cfee71b0174a.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=hanyihao@vivo.com \
    --cc=kernel@vivo.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).