| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) International Business Machines Corp., 2006 |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 6 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | | - * (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
|---|
| 12 | | - * the GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License |
|---|
| 15 | | - * along with this program; if not, write to the Free Software |
|---|
| 16 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 | 4 | * |
|---|
| 18 | 5 | * Author: Artem Bityutskiy (Битюцкий Артём) |
|---|
| 19 | 6 | */ |
|---|
| .. | .. |
|---|
| 612 | 599 | int err, pnum, scrub = 0, vol_id = vol->vol_id; |
|---|
| 613 | 600 | struct ubi_vid_io_buf *vidb; |
|---|
| 614 | 601 | struct ubi_vid_hdr *vid_hdr; |
|---|
| 615 | | - uint32_t uninitialized_var(crc); |
|---|
| 602 | + uint32_t crc; |
|---|
| 616 | 603 | |
|---|
| 617 | 604 | err = leb_read_lock(ubi, vol_id, lnum); |
|---|
| 618 | 605 | if (err) |
|---|
| .. | .. |
|---|
| 960 | 947 | int offset, int len) |
|---|
| 961 | 948 | { |
|---|
| 962 | 949 | struct ubi_device *ubi = vol->ubi; |
|---|
| 963 | | - int pnum, opnum, err, vol_id = vol->vol_id; |
|---|
| 950 | + int pnum, opnum, err, err2, vol_id = vol->vol_id; |
|---|
| 964 | 951 | |
|---|
| 965 | 952 | pnum = ubi_wl_get_peb(ubi); |
|---|
| 966 | 953 | if (pnum < 0) { |
|---|
| .. | .. |
|---|
| 995 | 982 | out_put: |
|---|
| 996 | 983 | up_read(&ubi->fm_eba_sem); |
|---|
| 997 | 984 | |
|---|
| 998 | | - if (err && pnum >= 0) |
|---|
| 999 | | - err = ubi_wl_put_peb(ubi, vol_id, lnum, pnum, 1); |
|---|
| 1000 | | - else if (!err && opnum >= 0) |
|---|
| 1001 | | - err = ubi_wl_put_peb(ubi, vol_id, lnum, opnum, 0); |
|---|
| 985 | + if (err && pnum >= 0) { |
|---|
| 986 | + err2 = ubi_wl_put_peb(ubi, vol_id, lnum, pnum, 1); |
|---|
| 987 | + if (err2) { |
|---|
| 988 | + ubi_warn(ubi, "failed to return physical eraseblock %d, error %d", |
|---|
| 989 | + pnum, err2); |
|---|
| 990 | + } |
|---|
| 991 | + } else if (!err && opnum >= 0) { |
|---|
| 992 | + err2 = ubi_wl_put_peb(ubi, vol_id, lnum, opnum, 0); |
|---|
| 993 | + if (err2) { |
|---|
| 994 | + ubi_warn(ubi, "failed to return physical eraseblock %d, error %d", |
|---|
| 995 | + opnum, err2); |
|---|
| 996 | + } |
|---|
| 997 | + } |
|---|
| 1002 | 998 | |
|---|
| 1003 | 999 | return err; |
|---|
| 1004 | 1000 | } |
|---|