if (stream)
                        return NULL;
 
-               /*
-                * Set the pad to 0 on error as this is aligned with the
-                * behaviour of the pad state information access functions. The
-                * purpose of setting pad to 0 here is to avoid accessing memory
-                * outside the pads array, but still issuing warning of the
-                * invalid access while making the caller's error handling
-                * easier.
-                */
-               if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
-                       pad = 0;
+               if (pad >= state->sd->entity.num_pads)
+                       return NULL;
 
                return &state->pads[pad].format;
        }
                if (stream)
                        return NULL;
 
-               /*
-                * Set the pad to 0 on error as this is aligned with the
-                * behaviour of the pad state information access functions. The
-                * purpose of setting pad to 0 here is to avoid accessing memory
-                * outside the pads array, but still issuing warning of the
-                * invalid access while making the caller's error handling
-                * easier.
-                */
-               if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
-                       pad = 0;
+               if (pad >= state->sd->entity.num_pads)
+                       return NULL;
 
                return &state->pads[pad].crop;
        }
                if (stream)
                        return NULL;
 
-               /*
-                * Set the pad to 0 on error as this is aligned with the
-                * behaviour of the pad state information access functions. The
-                * purpose of setting pad to 0 here is to avoid accessing memory
-                * outside the pads array, but still issuing warning of the
-                * invalid access while making the caller's error handling
-                * easier.
-                */
-               if (WARN_ON_ONCE(pad >= state->sd->entity.num_pads))
-                       pad = 0;
+               if (pad >= state->sd->entity.num_pads)
+                       return NULL;
 
                return &state->pads[pad].compose;
        }