Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: cmos: clean up cmos_nvram_read()/cmos_nvram_write()

The change removes redundant sysfs binary file boundary checks, since
this task is already done on caller side in fs/sysfs/file.c

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Vladimir Zapolskiy and committed by
Alexandre Belloni
a3781639 3c217e51

-13
-13
drivers/rtc/rtc-cmos.c
··· 467 467 { 468 468 int retval; 469 469 470 - if (unlikely(off >= attr->size)) 471 - return 0; 472 - if (unlikely(off < 0)) 473 - return -EINVAL; 474 - if ((off + count) > attr->size) 475 - count = attr->size - off; 476 - 477 470 off += NVRAM_OFFSET; 478 471 spin_lock_irq(&rtc_lock); 479 472 for (retval = 0; count; count--, off++, retval++) { ··· 491 498 int retval; 492 499 493 500 cmos = dev_get_drvdata(container_of(kobj, struct device, kobj)); 494 - if (unlikely(off >= attr->size)) 495 - return -EFBIG; 496 - if (unlikely(off < 0)) 497 - return -EINVAL; 498 - if ((off + count) > attr->size) 499 - count = attr->size - off; 500 501 501 502 /* NOTE: on at least PCs and Ataris, the boot firmware uses a 502 503 * checksum on part of the NVRAM data. That's currently ignored