Skip to content

Commit

Permalink
time: Fix signedness bug in sysfs_get_uname() and its callers
Browse files Browse the repository at this point in the history
sysfs_get_uname() is erroneously declared as returning size_t even
though it may return a negative value, specifically -EINVAL.  Its
callers then check whether its return value is less than zero and indeed
that is never the case for size_t.

This patch changes sysfs_get_uname() to return ssize_t and makes sure
its callers use ssize_t accordingly.

Signed-off-by: Patrick Palka <patrick@parcs.ath.cx>
[jstultz: Didn't apply cleanly, as a similar partial fix was also applied
so had to resolve the collisions]
Signed-off-by: John Stultz <john.stultz@linaro.org>
  • Loading branch information
Patrick Palka authored and John Stultz committed Oct 18, 2013
1 parent b7bc50e commit 891292a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kernel/time/clockevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static ssize_t sysfs_unbind_tick_dev(struct device *dev,
const char *buf, size_t count)
{
char name[CS_NAME_LEN];
size_t ret = sysfs_get_uname(buf, name, count);
ssize_t ret = sysfs_get_uname(buf, name, count);
struct clock_event_device *ce;

if (ret < 0)
Expand Down
2 changes: 1 addition & 1 deletion kernel/time/clocksource.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ sysfs_show_current_clocksources(struct device *dev,
return count;
}

size_t sysfs_get_uname(const char *buf, char *dst, size_t cnt)
ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt)
{
size_t ret = cnt;

Expand Down
2 changes: 1 addition & 1 deletion kernel/time/tick-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern void tick_install_replacement(struct clock_event_device *dev);

extern void clockevents_shutdown(struct clock_event_device *dev);

extern size_t sysfs_get_uname(const char *buf, char *dst, size_t cnt);
extern ssize_t sysfs_get_uname(const char *buf, char *dst, size_t cnt);

/*
* NO_HZ / high resolution timer shared code
Expand Down

0 comments on commit 891292a

Please sign in to comment.