Commit b5f0c188 authored by Mukesh Ojha's avatar Mukesh Ojha Committed by Treehugger Robot
Browse files

FROMGIT: pinmux: Use sequential access to access desc->pinmux data

When two client of the same gpio call pinctrl_select_state() for the
same functionality, we are seeing NULL pointer issue while accessing
desc->mux_owner.

Let's say two processes A, B executing in pin_request() for the same pin
and process A updates the desc->mux_usecount but not yet updated the
desc->mux_owner while process B see the desc->mux_usecount which got
updated by A path and further executes strcmp and while accessing
desc->mux_owner it crashes with NULL pointer.

Serialize the access to mux related setting with a mutex lock.

	cpu0 (process A)			cpu1(process B)

pinctrl_select_state() {		  pinctrl_select_state() {
  pin_request() {				pin_request() {
  ...
						 ....
    } else {
         desc->mux_usecount++;
    						desc->mux_usecount && strcmp(desc->mux_owner, owner)) {

         if (desc->mux_usecount > 1)
               return 0;
         desc->mux_owner = owner;

  }						}

Bug: 378985320
Bug: 376023321
Link: https://lore.kernel.org/lkml/20241014192930.1539673-1-quic_mojha@quicinc.com/


Signed-off-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
(cherry picked from commit 5a3e85c3
 git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git

 for-next)
Change-Id: Ib417544f0dcc5174d6f9b01d0243c19162f82fff
Signed-off-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
(cherry picked from commit 54b58c87)
parent 16e19e7a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment