mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "weiyongjun (A)" <weiyongjun1@huawei.com>
To: Yang Yingliang <yangyingliang@huawei.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>
Subject: Re: [PATCH net-next] net: mscc: ocelot: check return value after calling platform_get_resource()
Date: Fri, 4 Jun 2021 18:07:18 +0800	[thread overview]
Message-ID: <3592374c-4dd9-c489-bb5f-bd6ee0f942b6@huawei.com> (raw)
In-Reply-To: <20210604093234.3408625-1-yangyingliang@huawei.com>


> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   drivers/net/dsa/ocelot/seville_vsc9953.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
> index 84f93a874d50..b514e2d05b6f 100644
> --- a/drivers/net/dsa/ocelot/seville_vsc9953.c
> +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
> @@ -1206,6 +1206,10 @@ static int seville_probe(struct platform_device *pdev)
>   	felix->info = &seville_info_vsc9953;
>   
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res) {
> +		err = -EINVAL;
> +		dev_err(&pdev->dev, "Invalid resource\n");


should 'goto err_alloc_felix;'


> +	}
>   	felix->switch_base = res->start;
>   
>   	ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);

      reply	other threads:[~2021-06-04 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04  9:32 Yang Yingliang
2021-06-04 10:07 ` weiyongjun (A) [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=3592374c-4dd9-c489-bb5f-bd6ee0f942b6@huawei.com \
    --to=weiyongjun1@huawei.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vladimir.oltean@nxp.com \
    --cc=yangyingliang@huawei.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®