Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd04fefe authored by Rahul Sharma's avatar Rahul Sharma Committed by Gerrit - the friendly Code Review server
Browse files

msm: ais: Synchronize v4l2 subscribe and unsubscribe event



Serializing msm_subscribe_event and msm_unsubscribe_event to
prevent possibility of use-after-free if same event is
unsubcribed before v4l2 subscribe and unsubscribe event.

Change-Id: Ia5ba7aa1338982b3a99616a2981e415c28f8b4a6
Signed-off-by: default avatarRahul Sharma <sharah@codeaurora.org>
parent a2143369
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -462,7 +462,9 @@ static int camera_v4l2_subscribe_event(struct v4l2_fh *fh,
	int rc = 0;
	struct camera_v4l2_private *sp = fh_to_private(fh);

	mutex_lock(&sp->lock);
	rc = v4l2_event_subscribe(&sp->fh, sub, 5, NULL);
	mutex_unlock(&sp->lock);

	return rc;
}
@@ -473,7 +475,9 @@ static int camera_v4l2_unsubscribe_event(struct v4l2_fh *fh,
	int rc = 0;
	struct camera_v4l2_private *sp = fh_to_private(fh);

	mutex_lock(&sp->lock);
	rc = v4l2_event_unsubscribe(&sp->fh, sub);
	mutex_unlock(&sp->lock);

	return rc;
}