Commit 761b4cf3 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman
Browse files

misc: eeprom_93xx46: Convert to use kstrtox()



sscanf() is a heavy one and moreover requires additional boundary checks.
Convert driver to use kstrtobool() in eeprom_93xx46_store_erase().

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240508184905.2102633-8-andriy.shevchenko@linux.intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 16389850
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/kstrtox.h>
#include <linux/log2.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
@@ -366,9 +366,13 @@ static ssize_t eeprom_93xx46_store_erase(struct device *dev,
					 const char *buf, size_t count)
{
	struct eeprom_93xx46_dev *edev = dev_get_drvdata(dev);
	int erase = 0, ret;
	bool erase;
	int ret;

	ret = kstrtobool(buf, &erase);
	if (ret)
		return ret;

	sscanf(buf, "%d", &erase);
	if (erase) {
		ret = eeprom_93xx46_ew(edev, 1);
		if (ret)