From patchwork Fri Mar 1 00:43:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 15173 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 095D723E1A for ; Fri, 1 Mar 2013 00:44:09 +0000 (UTC) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by fiordland.canonical.com (Postfix) with ESMTP id A579EA1935F for ; Fri, 1 Mar 2013 00:44:08 +0000 (UTC) Received: by mail-ve0-f177.google.com with SMTP id m1so2439912ves.36 for ; Thu, 28 Feb 2013 16:44:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=jWP/Ln7puMTqrGJWoWEec5EMN5rBwuVqcYiC6C+om2g=; b=lmBoeEviE45SksFSBc+qRdxd2Yigwt2iEIRewLXxhr3M5B66/D36r/NXZD434MH0gF kdBv52/MM85r6l5R7lWBVVpeAS3gkcoYxeaEG5fNco7APSG7BfxTph3OU4UKS3RDYJqX 4Rf92sC+D9miinb/Go2JuCqd7RBOfCKkftJcIYo21JX34+iZyu4DpikeX2BkaDqpesQ/ XLtz3om6BKiPDV5ePmckk55fHmOFFg9t72rBPrR6klGgfYAgLqN4JnhUFrMBbJFbqPDF wmAb1EnoSyDm/hFTqPWlwfpvwgcwlwAk+XMg+niAlBDTZsye+SxChITOKg8fi68W4E1A QPiA== X-Received: by 10.52.29.18 with SMTP id f18mr2892863vdh.57.1362098648223; Thu, 28 Feb 2013 16:44:08 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp658veb; Thu, 28 Feb 2013 16:44:07 -0800 (PST) X-Received: by 10.66.163.104 with SMTP id yh8mr15964119pab.170.1362098647374; Thu, 28 Feb 2013 16:44:07 -0800 (PST) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id oj4si10243692pbb.323.2013.02.28.16.44.07 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 16:44:07 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: by mail-pb0-f50.google.com with SMTP id up1so1391491pbc.37 for ; Thu, 28 Feb 2013 16:44:07 -0800 (PST) X-Received: by 10.68.225.40 with SMTP id rh8mr357100pbc.137.1362098646894; Thu, 28 Feb 2013 16:44:06 -0800 (PST) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPS id dx17sm10914892pac.17.2013.02.28.16.44.05 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 16:44:06 -0800 (PST) From: John Stultz To: lkml Cc: Rebecca Schultz Zavin , Maarten Lankhorst , Erik Gilling , Daniel Vetter , Rob Clark , Sumit Semwal , Greg KH , dri-devel@lists.freedesktop.org, Android Kernel Team , John Stultz Subject: [PATCH 17/30] staging: sw_sync: Fix error paths Date: Thu, 28 Feb 2013 16:43:13 -0800 Message-Id: <1362098606-26469-18-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1362098606-26469-1-git-send-email-john.stultz@linaro.org> References: <1362098606-26469-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQk/L6MbFvm7zLtqzktzSuG94ecMaZS/1KGrNqH+cI3z2M4RQqGR5cWAKgIH5nhDYYFg8k58 From: Rebecca Schultz Zavin Check the return value of get_unused_fd to make sure a valid file descriptor is returned. Make sure to call put_unused_fd even if an error occurs before the fd can be used. Cc: Maarten Lankhorst Cc: Erik Gilling Cc: Daniel Vetter Cc: Rob Clark Cc: Sumit Semwal Cc: Greg KH Cc: dri-devel@lists.freedesktop.org Cc: Android Kernel Team Signed-off-by: Rebecca Schultz Zavin Signed-off-by: John Stultz --- drivers/staging/android/sw_sync.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index d689760..d768893 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -170,8 +170,13 @@ long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, unsigned long arg) struct sync_fence *fence; struct sw_sync_create_fence_data data; - if (copy_from_user(&data, (void __user *)arg, sizeof(data))) - return -EFAULT; + if (fd < 0) + return fd; + + if (copy_from_user(&data, (void __user *)arg, sizeof(data))) { + err = -EFAULT; + goto err; + } pt = sw_sync_pt_create(obj, data.value); if (pt == NULL) {