hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mtd/mtdchar.c
....@@ -1,20 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright © 1999-2010 David Woodhouse <dwmw2@infradead.org>
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 the
12
- * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
- *
184 */
195
206 #include <linux/device.h>
....@@ -188,7 +174,7 @@
188174 break;
189175 case MTD_FILE_MODE_RAW:
190176 {
191
- struct mtd_oob_ops ops;
177
+ struct mtd_oob_ops ops = {};
192178
193179 ops.mode = MTD_OPS_RAW;
194180 ops.datbuf = kbuf;
....@@ -282,7 +268,7 @@
282268
283269 case MTD_FILE_MODE_RAW:
284270 {
285
- struct mtd_oob_ops ops;
271
+ struct mtd_oob_ops ops = {};
286272
287273 ops.mode = MTD_OPS_RAW;
288274 ops.datbuf = kbuf;
....@@ -363,15 +349,16 @@
363349 uint64_t start, uint32_t length, void __user *ptr,
364350 uint32_t __user *retp)
365351 {
352
+ struct mtd_info *master = mtd_get_master(mtd);
366353 struct mtd_file_info *mfi = file->private_data;
367
- struct mtd_oob_ops ops;
354
+ struct mtd_oob_ops ops = {};
368355 uint32_t retlen;
369356 int ret = 0;
370357
371358 if (length > 4096)
372359 return -EINVAL;
373360
374
- if (!mtd->_write_oob)
361
+ if (!master->_write_oob)
375362 return -EOPNOTSUPP;
376363
377364 ops.ooblen = length;
....@@ -405,7 +392,7 @@
405392 uint32_t __user *retp)
406393 {
407394 struct mtd_file_info *mfi = file->private_data;
408
- struct mtd_oob_ops ops;
395
+ struct mtd_oob_ops ops = {};
409396 int ret = 0;
410397
411398 if (length > 4096)
....@@ -597,8 +584,9 @@
597584 static int mtdchar_write_ioctl(struct mtd_info *mtd,
598585 struct mtd_write_req __user *argp)
599586 {
587
+ struct mtd_info *master = mtd_get_master(mtd);
600588 struct mtd_write_req req;
601
- struct mtd_oob_ops ops;
589
+ struct mtd_oob_ops ops = {};
602590 const void __user *usr_data, *usr_oob;
603591 int ret;
604592
....@@ -608,9 +596,8 @@
608596 usr_data = (const void __user *)(uintptr_t)req.usr_data;
609597 usr_oob = (const void __user *)(uintptr_t)req.usr_oob;
610598
611
- if (!mtd->_write_oob)
599
+ if (!master->_write_oob)
612600 return -EOPNOTSUPP;
613
-
614601 ops.mode = req.mode;
615602 ops.len = (size_t)req.len;
616603 ops.ooblen = (size_t)req.ooblen;
....@@ -646,6 +633,7 @@
646633 {
647634 struct mtd_file_info *mfi = file->private_data;
648635 struct mtd_info *mtd = mfi->mtd;
636
+ struct mtd_info *master = mtd_get_master(mtd);
649637 void __user *argp = (void __user *)arg;
650638 int ret = 0;
651639 struct mtd_info_user info;
....@@ -874,7 +862,7 @@
874862 {
875863 struct nand_oobinfo oi;
876864
877
- if (!mtd->ooblayout)
865
+ if (!master->ooblayout)
878866 return -EOPNOTSUPP;
879867
880868 ret = get_oobinfo(mtd, &oi);
....@@ -968,7 +956,7 @@
968956 {
969957 struct nand_ecclayout_user *usrlay;
970958
971
- if (!mtd->ooblayout)
959
+ if (!master->ooblayout)
972960 return -EOPNOTSUPP;
973961
974962 usrlay = kmalloc(sizeof(*usrlay), GFP_KERNEL);