* [linux-next:master 5567/5842] fs/f2fs/sysfs.c:491 __sbi_store() warn: unsigned 't' is never less than zero.
@ 2021-12-09 0:18 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-12-09 0:18 UTC (permalink / raw)
To: Daeho Jeong; +Cc: kbuild-all, Linux Memory Management List, Jaegeuk Kim
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 4eee8d0b64ecc3231040fa68ba750317ffca5c52
commit: 38f953da2e3517444394000211c11cc82e67eb13 [5567/5842] f2fs: add gc_urgent_high_remaining sysfs node
config: i386-randconfig-m021-20211207 (https://download.01.org/0day-ci/archive/20211209/202112090853.JdT0VEOq-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
smatch warnings:
fs/f2fs/sysfs.c:491 __sbi_store() warn: unsigned 't' is never less than zero.
vim +/t +491 fs/f2fs/sysfs.c
332
333 static ssize_t __sbi_store(struct f2fs_attr *a,
334 struct f2fs_sb_info *sbi,
335 const char *buf, size_t count)
336 {
337 unsigned char *ptr;
338 unsigned long t;
339 unsigned int *ui;
340 ssize_t ret;
341
342 ptr = __struct_ptr(sbi, a->struct_type);
343 if (!ptr)
344 return -EINVAL;
345
346 if (!strcmp(a->attr.name, "extension_list")) {
347 const char *name = strim((char *)buf);
348 bool set = true, hot;
349
350 if (!strncmp(name, "[h]", 3))
351 hot = true;
352 else if (!strncmp(name, "[c]", 3))
353 hot = false;
354 else
355 return -EINVAL;
356
357 name += 3;
358
359 if (*name == '!') {
360 name++;
361 set = false;
362 }
363
364 if (!strlen(name) || strlen(name) >= F2FS_EXTENSION_LEN)
365 return -EINVAL;
366
367 down_write(&sbi->sb_lock);
368
369 ret = f2fs_update_extension_list(sbi, name, hot, set);
370 if (ret)
371 goto out;
372
373 ret = f2fs_commit_super(sbi, false);
374 if (ret)
375 f2fs_update_extension_list(sbi, name, hot, !set);
376 out:
377 up_write(&sbi->sb_lock);
378 return ret ? ret : count;
379 }
380
381 if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
382 const char *name = strim((char *)buf);
383 struct ckpt_req_control *cprc = &sbi->cprc_info;
384 int class;
385 long data;
386 int ret;
387
388 if (!strncmp(name, "rt,", 3))
389 class = IOPRIO_CLASS_RT;
390 else if (!strncmp(name, "be,", 3))
391 class = IOPRIO_CLASS_BE;
392 else
393 return -EINVAL;
394
395 name += 3;
396 ret = kstrtol(name, 10, &data);
397 if (ret)
398 return ret;
399 if (data >= IOPRIO_NR_LEVELS || data < 0)
400 return -EINVAL;
401
402 cprc->ckpt_thread_ioprio = IOPRIO_PRIO_VALUE(class, data);
403 if (test_opt(sbi, MERGE_CHECKPOINT)) {
404 ret = set_task_ioprio(cprc->f2fs_issue_ckpt,
405 cprc->ckpt_thread_ioprio);
406 if (ret)
407 return ret;
408 }
409
410 return count;
411 }
412
413 ui = (unsigned int *)(ptr + a->offset);
414
415 ret = kstrtoul(skip_spaces(buf), 0, &t);
416 if (ret < 0)
417 return ret;
418 #ifdef CONFIG_F2FS_FAULT_INJECTION
419 if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX))
420 return -EINVAL;
421 if (a->struct_type == FAULT_INFO_RATE && t >= UINT_MAX)
422 return -EINVAL;
423 #endif
424 if (a->struct_type == RESERVED_BLOCKS) {
425 spin_lock(&sbi->stat_lock);
426 if (t > (unsigned long)(sbi->user_block_count -
427 F2FS_OPTION(sbi).root_reserved_blocks)) {
428 spin_unlock(&sbi->stat_lock);
429 return -EINVAL;
430 }
431 *ui = t;
432 sbi->current_reserved_blocks = min(sbi->reserved_blocks,
433 sbi->user_block_count - valid_user_blocks(sbi));
434 spin_unlock(&sbi->stat_lock);
435 return count;
436 }
437
438 if (!strcmp(a->attr.name, "discard_granularity")) {
439 if (t == 0 || t > MAX_PLIST_NUM)
440 return -EINVAL;
441 if (!f2fs_block_unit_discard(sbi))
442 return -EINVAL;
443 if (t == *ui)
444 return count;
445 *ui = t;
446 return count;
447 }
448
449 if (!strcmp(a->attr.name, "migration_granularity")) {
450 if (t == 0 || t > sbi->segs_per_sec)
451 return -EINVAL;
452 }
453
454 if (!strcmp(a->attr.name, "trim_sections"))
455 return -EINVAL;
456
457 if (!strcmp(a->attr.name, "gc_urgent")) {
458 if (t == 0) {
459 sbi->gc_mode = GC_NORMAL;
460 } else if (t == 1) {
461 sbi->gc_mode = GC_URGENT_HIGH;
462 if (sbi->gc_thread) {
463 sbi->gc_thread->gc_wake = 1;
464 wake_up_interruptible_all(
465 &sbi->gc_thread->gc_wait_queue_head);
466 wake_up_discard_thread(sbi, true);
467 }
468 } else if (t == 2) {
469 sbi->gc_mode = GC_URGENT_LOW;
470 } else {
471 return -EINVAL;
472 }
473 return count;
474 }
475 if (!strcmp(a->attr.name, "gc_idle")) {
476 if (t == GC_IDLE_CB) {
477 sbi->gc_mode = GC_IDLE_CB;
478 } else if (t == GC_IDLE_GREEDY) {
479 sbi->gc_mode = GC_IDLE_GREEDY;
480 } else if (t == GC_IDLE_AT) {
481 if (!sbi->am.atgc_enabled)
482 return -EINVAL;
483 sbi->gc_mode = GC_AT;
484 } else {
485 sbi->gc_mode = GC_NORMAL;
486 }
487 return count;
488 }
489
490 if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) {
> 491 if (t < 0)
492 return -EINVAL;
493
494 spin_lock(&sbi->gc_urgent_high_lock);
495 sbi->gc_urgent_high_limited = t == 0 ? false : true;
496 sbi->gc_urgent_high_remaining = t;
497 spin_unlock(&sbi->gc_urgent_high_lock);
498
499 return count;
500 }
501
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-09 0:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 0:18 [linux-next:master 5567/5842] fs/f2fs/sysfs.c:491 __sbi_store() warn: unsigned 't' is never less than zero kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox