From: Christophe LEROY <christophe.leroy@c-s.fr>
To: Wen Yang <wen.yang99@zte.com.cn>, qiang.zhao@nxp.com
Cc: wang.yi59@zte.com.cn, zhong.weidong@zte.com.cn,
linux-kernel@vger.kernel.org, leoyang.li@nxp.com,
Julia Lawall <julia.lawall@lip6.fr>,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/4] soc/fsl/qe: fix potential NULL pointer dereference in ucc_of_parse_tdm
Date: Wed, 21 Nov 2018 11:45:26 +0100 [thread overview]
Message-ID: <d69e7c77-e9fa-470a-db9f-ff9cd0476334@c-s.fr> (raw)
In-Reply-To: <1542786111-18648-1-git-send-email-wen.yang99@zte.com.cn>
Le 21/11/2018 à 08:41, Wen Yang a écrit :
> This patch fixes a possible null pointer dereference in
> ucc_of_parse_tdm, detected by the semantic patch
> deref_null.cocci, with the following warning:
>
> ./drivers/soc/fsl/qe/qe_tdm.c:177:21-24: ERROR: pdev is NULL but dereferenced.
>
> The following code has potential null pointer references:
> pdev = of_find_device_by_node(np2);
> if (!pdev) {
> ret = -EINVAL;
> pr_err("%pOFn: failed to lookup pdev\n", np2);
> of_node_put(np2);
> goto err_miss_siram_property;
> }
> ...
> err_miss_siram_property:
> devm_iounmap(&pdev->dev, utdm->si_regs);
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Reviewed-by: Tan Hu <tan.hu@zte.com.cn>
> CC: Julia Lawall <julia.lawall@lip6.fr>
> ---
> drivers/soc/fsl/qe/qe_tdm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c
> index f78c346..166378b 100644
> --- a/drivers/soc/fsl/qe/qe_tdm.c
> +++ b/drivers/soc/fsl/qe/qe_tdm.c
> @@ -174,7 +174,8 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm,
> return ret;
>
> err_miss_siram_property:
> - devm_iounmap(&pdev->dev, utdm->si_regs);
> + if (pdev)
> + devm_iounmap(&pdev->dev, utdm->si_regs);
You are just hiding the issue, not fixing it.
The problem is that pdev gets modified, so in any case that
devm_iounmap() will fail even when the new pdev is valid, because the
iomap was done with a different pdev.
Christophe
> return ret;
> }
> EXPORT_SYMBOL(ucc_of_parse_tdm);
>
next prev parent reply other threads:[~2018-11-21 10:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 7:41 [PATCH 2/4] soc/fsl/qe: fix potential NULL pointer dereference in ucc_of_parse_tdm Wen Yang
2018-11-21 10:45 ` Christophe LEROY [this message]
2018-11-22 2:41 ` 答复: Re: [PATCH 2/4] soc/fsl/qe: fix potential NULL pointer dereference inucc_of_parse_tdm wen.yang99
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=d69e7c77-e9fa-470a-db9f-ff9cd0476334@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=julia.lawall@lip6.fr \
--cc=leoyang.li@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=qiang.zhao@nxp.com \
--cc=wang.yi59@zte.com.cn \
--cc=wen.yang99@zte.com.cn \
--cc=zhong.weidong@zte.com.cn \
/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).