kernel: improve ubi auto attach code readability
authorMathias Kresin <dev@kresin.me>
Sat, 7 Jul 2018 23:38:08 +0000 (01:38 +0200)
committerMathias Kresin <dev@kresin.me>
Tue, 24 Jul 2018 20:24:21 +0000 (22:24 +0200)
commitfdf6760cda15b2710287c66c9969a3ed527793d8
treea4ebd183378dd0a2d37c2c0d979e2c535b3ac303
parent354de22bad37ef8f91f9a8f65b65f402713629ec
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>
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