From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0109.outbound.protection.outlook.com ([104.47.32.109]:39556 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729123AbeIGFPG (ORCPT ); Fri, 7 Sep 2018 01:15:06 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Nicholas Mc Guire , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.18 57/88] staging: bcm2835-camera: fix timeout handling in wait_for_completion_timeout Date: Fri, 7 Sep 2018 00:36:33 +0000 Message-ID: <20180907003547.57567-57-alexander.levin@microsoft.com> References: <20180907003547.57567-1-alexander.levin@microsoft.com> In-Reply-To: <20180907003547.57567-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Nicholas Mc Guire [ Upstream commit b7afce51d95726a619743aaad8870db66dfa1479 ] wait_for_completion_timeout returns unsigned long not int so a variable of proper type is introduced. Further the check for <=3D 0 is ambiguous and sh= ould be =3D=3D 0 here indicating timeout which is the only error case so no addi= tional check needed here. Signed-off-by: Nicholas Mc Guire Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera dr= iver.") Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- .../staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/dr= ivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index f5b5ead6347c..51e5b04ff0f5 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -630,6 +630,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_= instance *instance, { struct mmal_msg_context *msg_context; int ret; + unsigned long timeout; =20 /* payload size must not cause message to exceed max size */ if (payload_len > @@ -668,11 +669,11 @@ static int send_synchronous_mmal_msg(struct vchiq_mma= l_instance *instance, return ret; } =20 - ret =3D wait_for_completion_timeout(&msg_context->u.sync.cmplt, 3 * HZ); - if (ret <=3D 0) { - pr_err("error %d waiting for sync completion\n", ret); - if (ret =3D=3D 0) - ret =3D -ETIME; + timeout =3D wait_for_completion_timeout(&msg_context->u.sync.cmplt, + 3 * HZ); + if (timeout =3D=3D 0) { + pr_err("timed out waiting for sync completion\n"); + ret =3D -ETIME; /* todo: what happens if the message arrives after aborting */ release_msg_context(msg_context); return ret; --=20 2.17.1