Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping write union fix. #906

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions arch/alpha/kernel/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,18 @@ union remote_data {
long retval;
};

static void
do_remote_read(void *data)
static void do_remote_read(void *data)
{
union remote_data *x = data;
x->retval = alpha_rtc_read_time(NULL, x->tm);
union remote_data *x = data;
// Use temporary variables to avoid overlapping read/write
struct tm temp_tm;
int temp_retval;

temp_retval = alpha_rtc_read_time(NULL, &temp_tm);

// Now copy the temporary values into the union
x->tm = temp_tm;
x->retval = temp_retval;
}

static int
Expand All @@ -174,11 +181,17 @@ remote_read_time(struct device *dev, struct rtc_time *tm)
return alpha_rtc_read_time(NULL, tm);
}

static void
do_remote_set(void *data)
static void do_remote_set(void *data)
{
union remote_data *x = data;
x->retval = alpha_rtc_set_time(NULL, x->tm);
union remote_data *x = data;
// Use a temporary variable to avoid overlapping read/write
struct tm temp_tm = x->tm;
int temp_retval;

temp_retval = alpha_rtc_set_time(NULL, &temp_tm);

// Now copy the temporary retval into the union
x->retval = temp_retval;
}

static int
Expand Down