vt: fix locking around vt_bind/vt_unbind
Currently vt_bind and vt_unbind access at least the con_driver object and registered_con_driver array without holding the console lock. Fix this by locking around the whole function in each case. Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2cf30f752c
commit
4c215fe8e2
|
@ -3318,11 +3318,8 @@ static int vt_bind(struct con_driver *con)
|
||||||
if (first == 0 && last == MAX_NR_CONSOLES -1)
|
if (first == 0 && last == MAX_NR_CONSOLES -1)
|
||||||
deflt = 1;
|
deflt = 1;
|
||||||
|
|
||||||
if (first != -1) {
|
if (first != -1)
|
||||||
console_lock();
|
|
||||||
do_bind_con_driver(csw, first, last, deflt);
|
do_bind_con_driver(csw, first, last, deflt);
|
||||||
console_unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
first = -1;
|
first = -1;
|
||||||
last = -1;
|
last = -1;
|
||||||
|
@ -3362,9 +3359,7 @@ static int vt_unbind(struct con_driver *con)
|
||||||
deflt = 1;
|
deflt = 1;
|
||||||
|
|
||||||
if (first != -1) {
|
if (first != -1) {
|
||||||
console_lock();
|
|
||||||
ret = do_unbind_con_driver(csw, first, last, deflt);
|
ret = do_unbind_con_driver(csw, first, last, deflt);
|
||||||
console_unlock();
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3394,11 +3389,15 @@ static ssize_t store_bind(struct device *dev, struct device_attribute *attr,
|
||||||
struct con_driver *con = dev_get_drvdata(dev);
|
struct con_driver *con = dev_get_drvdata(dev);
|
||||||
int bind = simple_strtoul(buf, NULL, 0);
|
int bind = simple_strtoul(buf, NULL, 0);
|
||||||
|
|
||||||
|
console_lock();
|
||||||
|
|
||||||
if (bind)
|
if (bind)
|
||||||
vt_bind(con);
|
vt_bind(con);
|
||||||
else
|
else
|
||||||
vt_unbind(con);
|
vt_unbind(con);
|
||||||
|
|
||||||
|
console_unlock();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue