kernel: improve ubi auto attach code readability
authorMathias Kresin <dev@kresin.me>
Sat, 7 Jul 2018 23:38:08 +0000 (01:38 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 18 Dec 2018 08:50:47 +0000 (09:50 +0100)
commitedc2af2be931c43a1ee111800737b08bacc60126
treea1b7fa94aa9872a954a87b4a2140d63211e22218
parentc0673db23f1c98ccb9e5f71ec21b94153684fc80
kernel: improve ubi auto attach code readability

Move the put_mtd_device() called on multiple error conditions to a goto
label to use it later for more error conditions.

The early return on failed open of the mtd device and mismatching mtd
type allows to get rid of one level of indentation. By jumping to the
cleanup code, a refcount bug is fixed for the wrong flash type condition.

While at it, make clear that we only check for the UBI magic if the read
from flash was successful.

Signed-off-by: Mathias Kresin <dev@kresin.me>
(backported from fdf6760cda15b2710287c66c9969a3ed527793d8)
(rebased patches)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
target/linux/generic/pending-4.14/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch