From: Wen Yang <wen.yang99@zte.com.cn>
To: linux-kernel@vger.kernel.org
Cc: xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn,
cheng.shengyu@zte.com.cn, Wen Yang <wen.yang99@zte.com.cn>,
Scott Wood <oss@buserror.net>,
Kumar Gala <galak@kernel.crashing.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Markus Elfring <Markus.Elfring@web.de>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 2/2] powerpc/83xx: cleanup error paths in mpc831x_usb_cfg()
Date: Tue, 9 Jul 2019 19:12:48 +0800 [thread overview]
Message-ID: <1562670768-23178-3-git-send-email-wen.yang99@zte.com.cn> (raw)
In-Reply-To: <1562670768-23178-1-git-send-email-wen.yang99@zte.com.cn>
Rename the jump labels according to the cleanup they perform,
and move reference handling to simplify cleanup.
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Scott Wood <oss@buserror.net>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Markus Elfring <Markus.Elfring@web.de>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
arch/powerpc/platforms/83xx/usb.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
index 19dcef5..56b36fa 100644
--- a/arch/powerpc/platforms/83xx/usb.c
+++ b/arch/powerpc/platforms/83xx/usb.c
@@ -160,11 +160,9 @@ int mpc831x_usb_cfg(void)
/* Map USB SOC space */
ret = of_address_to_resource(np, 0, &res);
- if (ret) {
- of_node_put(immr_node);
- of_node_put(np);
- return ret;
- }
+ if (ret)
+ goto out_put_node;
+
usb_regs = ioremap(res.start, resource_size(&res));
/* Using on-chip PHY */
@@ -173,7 +171,7 @@ int mpc831x_usb_cfg(void)
u32 refsel;
if (of_device_is_compatible(immr_node, "fsl,mpc8308-immr"))
- goto out;
+ goto out_unmap;
if (of_device_is_compatible(immr_node, "fsl,mpc8315-immr"))
refsel = CONTROL_REFSEL_24MHZ;
@@ -200,8 +198,9 @@ int mpc831x_usb_cfg(void)
ret = -EINVAL;
}
-out:
+out_unmap:
iounmap(usb_regs);
+out_put_node:
of_node_put(immr_node);
of_node_put(np);
return ret;
--
2.9.5
next prev parent reply other threads:[~2019-07-09 11:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 11:12 [PATCH 0/2] fix use-after-free in mpc831x_usb_cfg() and do some cleanups Wen Yang
2019-07-09 11:12 ` [PATCH 1/2] powerpc/83xx: fix use-after-free in mpc831x_usb_cfg() Wen Yang
2019-07-10 7:19 ` [1/2] " Markus Elfring
2019-07-09 11:12 ` Wen Yang [this message]
2019-07-09 16:14 ` [PATCH 0/2] fix use-after-free in mpc831x_usb_cfg() and do some cleanups Markus Elfring
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=1562670768-23178-3-git-send-email-wen.yang99@zte.com.cn \
--to=wen.yang99@zte.com.cn \
--cc=Markus.Elfring@web.de \
--cc=benh@kernel.crashing.org \
--cc=cheng.shengyu@zte.com.cn \
--cc=galak@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=oss@buserror.net \
--cc=paulus@samba.org \
--cc=wang.yi59@zte.com.cn \
--cc=xue.zhihong@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).