From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [linux-next:master 7938/8210] fs/erofs/super.c:190 erofs_read_superblock() warn: passing the wrong variable to kunmap()
Date: Sat, 02 Nov 2019 12:33:11 +0300 [thread overview]
Message-ID: <20191102093311.GC21796@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 8879 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 49afce6d47fe05ee01f1a41129b835fe4cca7eea
commit: f0a6634246f9d8f73be2b22bdd475530914d22c7 [7938/8210] erofs: support superblock checksum
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
fs/erofs/super.c:190 erofs_read_superblock() warn: passing the wrong variable to kunmap()
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f0a6634246f9d8f73be2b22bdd475530914d22c7
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout f0a6634246f9d8f73be2b22bdd475530914d22c7
vim +190 fs/erofs/super.c
99634bf388db04 fs/erofs/super.c Gao Xiang 2019-09-04 123 static int erofs_read_superblock(struct super_block *sb)
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 124 {
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 125 struct erofs_sb_info *sbi;
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 126 struct page *page;
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 127 struct erofs_super_block *dsb;
7dd68b147d60e5 drivers/staging/erofs/super.c Thomas Weißschuh 2018-09-10 128 unsigned int blkszbits;
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 129 void *data;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 130 int ret;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 131
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 132 page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL);
517d6b9c6f71be fs/erofs/super.c Wei Yongjun 2019-09-18 133 if (IS_ERR(page)) {
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 134 erofs_err(sb, "cannot read erofs superblock");
517d6b9c6f71be fs/erofs/super.c Wei Yongjun 2019-09-18 135 return PTR_ERR(page);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 136 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 137
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 138 sbi = EROFS_SB(sb);
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 139
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 140 data = kmap(page);
^^^^^^^^^^^^^^^^^
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 141 dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 142
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 143 ret = -EINVAL;
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 144 if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 145 erofs_err(sb, "cannot find valid erofs superblock");
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 146 goto out;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 147 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 148
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 149 sbi->feature_compat = le32_to_cpu(dsb->feature_compat);
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 150 if (sbi->feature_compat & EROFS_FEATURE_COMPAT_SB_CHKSUM) {
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 151 ret = erofs_superblock_csum_verify(sb, data);
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 152 if (ret)
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 153 goto out;
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 154 }
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 155
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 156 blkszbits = dsb->blkszbits;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 157 /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
8d8a09b093d707 fs/erofs/super.c Gao Xiang 2019-08-30 158 if (blkszbits != LOG_BLOCK_SIZE) {
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 159 erofs_err(sb, "blksize %u isn't supported on this platform",
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 160 1 << blkszbits);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 161 goto out;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 162 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 163
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 164 if (!check_layout_compatibility(sb, dsb))
5efe5137f05bbb drivers/staging/erofs/super.c Gao Xiang 2019-06-13 165 goto out;
5efe5137f05bbb drivers/staging/erofs/super.c Gao Xiang 2019-06-13 166
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 167 sbi->blocks = le32_to_cpu(dsb->blocks);
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 168 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
b17500a0fdbae1 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 169 #ifdef CONFIG_EROFS_FS_XATTR
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 170 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
b17500a0fdbae1 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 171 #endif
8a76568225deae fs/erofs/super.c Gao Xiang 2019-09-04 172 sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 173 sbi->root_nid = le16_to_cpu(dsb->root_nid);
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 174 sbi->inos = le64_to_cpu(dsb->inos);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 175
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 176 sbi->build_time = le64_to_cpu(dsb->build_time);
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 177 sbi->build_time_nsec = le32_to_cpu(dsb->build_time_nsec);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 178
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 179 memcpy(&sb->s_uuid, dsb->uuid, sizeof(dsb->uuid));
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 180
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 181 ret = strscpy(sbi->volume_name, dsb->volume_name,
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 182 sizeof(dsb->volume_name));
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 183 if (ret < 0) { /* -E2BIG */
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 184 erofs_err(sb, "bad volume name without NIL terminator");
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 185 ret = -EFSCORRUPTED;
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 186 goto out;
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 187 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 188 ret = 0;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 189 out:
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 @190 kunmap(data);
^^^^^^^^^^^^
This should be kunmap(page);. kmap() and kmap_atomic() are tricky like
that.
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 191 put_page(page);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 192 return ret;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 193 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 194
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [linux-next:master 7938/8210] fs/erofs/super.c:190 erofs_read_superblock() warn: passing the wrong variable to kunmap()
Date: Sat, 02 Nov 2019 12:33:11 +0300 [thread overview]
Message-ID: <20191102093311.GC21796@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 8879 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 49afce6d47fe05ee01f1a41129b835fe4cca7eea
commit: f0a6634246f9d8f73be2b22bdd475530914d22c7 [7938/8210] erofs: support superblock checksum
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
fs/erofs/super.c:190 erofs_read_superblock() warn: passing the wrong variable to kunmap()
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f0a6634246f9d8f73be2b22bdd475530914d22c7
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout f0a6634246f9d8f73be2b22bdd475530914d22c7
vim +190 fs/erofs/super.c
99634bf388db04 fs/erofs/super.c Gao Xiang 2019-09-04 123 static int erofs_read_superblock(struct super_block *sb)
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 124 {
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 125 struct erofs_sb_info *sbi;
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 126 struct page *page;
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 127 struct erofs_super_block *dsb;
7dd68b147d60e5 drivers/staging/erofs/super.c Thomas Weißschuh 2018-09-10 128 unsigned int blkszbits;
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 129 void *data;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 130 int ret;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 131
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 132 page = read_mapping_page(sb->s_bdev->bd_inode->i_mapping, 0, NULL);
517d6b9c6f71be fs/erofs/super.c Wei Yongjun 2019-09-18 133 if (IS_ERR(page)) {
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 134 erofs_err(sb, "cannot read erofs superblock");
517d6b9c6f71be fs/erofs/super.c Wei Yongjun 2019-09-18 135 return PTR_ERR(page);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 136 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 137
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 138 sbi = EROFS_SB(sb);
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 139
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 140 data = kmap(page);
^^^^^^^^^^^^^^^^^
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 141 dsb = (struct erofs_super_block *)(data + EROFS_SUPER_OFFSET);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 142
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 143 ret = -EINVAL;
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 144 if (le32_to_cpu(dsb->magic) != EROFS_SUPER_MAGIC_V1) {
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 145 erofs_err(sb, "cannot find valid erofs superblock");
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 146 goto out;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 147 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 148
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 149 sbi->feature_compat = le32_to_cpu(dsb->feature_compat);
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 150 if (sbi->feature_compat & EROFS_FEATURE_COMPAT_SB_CHKSUM) {
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 151 ret = erofs_superblock_csum_verify(sb, data);
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 152 if (ret)
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 153 goto out;
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 154 }
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 155
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 156 blkszbits = dsb->blkszbits;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 157 /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
8d8a09b093d707 fs/erofs/super.c Gao Xiang 2019-08-30 158 if (blkszbits != LOG_BLOCK_SIZE) {
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 159 erofs_err(sb, "blksize %u isn't supported on this platform",
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 160 1 << blkszbits);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 161 goto out;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 162 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 163
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 164 if (!check_layout_compatibility(sb, dsb))
5efe5137f05bbb drivers/staging/erofs/super.c Gao Xiang 2019-06-13 165 goto out;
5efe5137f05bbb drivers/staging/erofs/super.c Gao Xiang 2019-06-13 166
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 167 sbi->blocks = le32_to_cpu(dsb->blocks);
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 168 sbi->meta_blkaddr = le32_to_cpu(dsb->meta_blkaddr);
b17500a0fdbae1 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 169 #ifdef CONFIG_EROFS_FS_XATTR
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 170 sbi->xattr_blkaddr = le32_to_cpu(dsb->xattr_blkaddr);
b17500a0fdbae1 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 171 #endif
8a76568225deae fs/erofs/super.c Gao Xiang 2019-09-04 172 sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 173 sbi->root_nid = le16_to_cpu(dsb->root_nid);
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 174 sbi->inos = le64_to_cpu(dsb->inos);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 175
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 176 sbi->build_time = le64_to_cpu(dsb->build_time);
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 177 sbi->build_time_nsec = le32_to_cpu(dsb->build_time_nsec);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 178
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 179 memcpy(&sb->s_uuid, dsb->uuid, sizeof(dsb->uuid));
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 180
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 181 ret = strscpy(sbi->volume_name, dsb->volume_name,
0259f209487c83 fs/erofs/super.c Gao Xiang 2019-09-04 182 sizeof(dsb->volume_name));
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 183 if (ret < 0) { /* -E2BIG */
4f761fa253b49f fs/erofs/super.c Gao Xiang 2019-09-04 184 erofs_err(sb, "bad volume name without NIL terminator");
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 185 ret = -EFSCORRUPTED;
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 186 goto out;
a64d9493f587f8 drivers/staging/erofs/super.c Gao Xiang 2019-08-18 187 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 188 ret = 0;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 189 out:
f0a6634246f9d8 fs/erofs/super.c Pratik Shinde 2019-10-30 @190 kunmap(data);
^^^^^^^^^^^^
This should be kunmap(page);. kmap() and kmap_atomic() are tricky like
that.
fe7c2423570dca fs/erofs/super.c Gao Xiang 2019-09-04 191 put_page(page);
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 192 return ret;
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 193 }
ba2b77a8202287 drivers/staging/erofs/super.c Gao Xiang 2018-07-26 194
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
next reply other threads:[~2019-11-02 9:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-02 9:33 Dan Carpenter [this message]
2019-11-02 9:33 ` [linux-next:master 7938/8210] fs/erofs/super.c:190 erofs_read_superblock() warn: passing the wrong variable to kunmap() Dan Carpenter
[not found] <20191103021836.GA6810@hsiangkao-HP-ZHAN-66-Pro-G1>
2019-11-04 6:52 ` Dan Carpenter
2019-11-04 6:52 ` Dan Carpenter
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=20191102093311.GC21796@kadam \
--to=dan.carpenter@oracle.com \
--cc=kbuild@lists.01.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.