aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/fadump.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index e1431800bfb9..04ea5c04fd24 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -1270,10 +1270,15 @@ static ssize_t fadump_release_memory_store(struct kobject *kobj,
1270 struct kobj_attribute *attr, 1270 struct kobj_attribute *attr,
1271 const char *buf, size_t count) 1271 const char *buf, size_t count)
1272{ 1272{
1273 int input = -1;
1274
1273 if (!fw_dump.dump_active) 1275 if (!fw_dump.dump_active)
1274 return -EPERM; 1276 return -EPERM;
1275 1277
1276 if (buf[0] == '1') { 1278 if (kstrtoint(buf, 0, &input))
1279 return -EINVAL;
1280
1281 if (input == 1) {
1277 /* 1282 /*
1278 * Take away the '/proc/vmcore'. We are releasing the dump 1283 * Take away the '/proc/vmcore'. We are releasing the dump
1279 * memory, hence it will not be valid anymore. 1284 * memory, hence it will not be valid anymore.
@@ -1307,21 +1312,25 @@ static ssize_t fadump_register_store(struct kobject *kobj,
1307 const char *buf, size_t count) 1312 const char *buf, size_t count)
1308{ 1313{
1309 int ret = 0; 1314 int ret = 0;
1315 int input = -1;
1310 1316
1311 if (!fw_dump.fadump_enabled || fdm_active) 1317 if (!fw_dump.fadump_enabled || fdm_active)
1312 return -EPERM; 1318 return -EPERM;
1313 1319
1320 if (kstrtoint(buf, 0, &input))
1321 return -EINVAL;
1322
1314 mutex_lock(&fadump_mutex); 1323 mutex_lock(&fadump_mutex);
1315 1324
1316 switch (buf[0]) { 1325 switch (input) {
1317 case '0': 1326 case 0:
1318 if (fw_dump.dump_registered == 0) { 1327 if (fw_dump.dump_registered == 0) {
1319 goto unlock_out; 1328 goto unlock_out;
1320 } 1329 }
1321 /* Un-register Firmware-assisted dump */ 1330 /* Un-register Firmware-assisted dump */
1322 fadump_unregister_dump(&fdm); 1331 fadump_unregister_dump(&fdm);
1323 break; 1332 break;
1324 case '1': 1333 case 1:
1325 if (fw_dump.dump_registered == 1) { 1334 if (fw_dump.dump_registered == 1) {
1326 ret = -EEXIST; 1335 ret = -EEXIST;
1327 goto unlock_out; 1336 goto unlock_out;