forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/fs/jfs/jfs_dmap.c
....@@ -1,20 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) International Business Machines Corp., 2000-2004
34 * Portions Copyright (C) Tino Reichardt, 2012
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13
- * the GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
185 */
196
207 #include <linux/fs.h>
....@@ -161,6 +148,7 @@
161148 * 0 - success
162149 * -ENOMEM - insufficient memory
163150 * -EIO - i/o error
151
+ * -EINVAL - wrong bmap data
164152 */
165153 int dbMount(struct inode *ipbmap)
166154 {
....@@ -192,6 +180,12 @@
192180 bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
193181 bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
194182 bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag);
183
+ if (!bmp->db_numag) {
184
+ release_metapage(mp);
185
+ kfree(bmp);
186
+ return -EINVAL;
187
+ }
188
+
195189 bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel);
196190 bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag);
197191 bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref);
....@@ -391,7 +385,8 @@
391385 }
392386
393387 /* write the last buffer. */
394
- write_metapage(mp);
388
+ if (mp)
389
+ write_metapage(mp);
395390
396391 IREAD_UNLOCK(ipbmap);
397392
....@@ -4040,7 +4035,6 @@
40404035 */
40414036 #define MAXL0PAGES (1 + LPERCTL)
40424037 #define MAXL1PAGES (1 + LPERCTL * MAXL0PAGES)
4043
-#define MAXL2PAGES (1 + LPERCTL * MAXL1PAGES)
40444038
40454039 /*
40464040 * convert number of map pages to the zero origin top dmapctl level