From patchwork Fri Dec 13 22:23:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22387 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C6D823FBA for ; Fri, 13 Dec 2013 22:26:41 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf7436196pbc.0 for ; Fri, 13 Dec 2013 14:26:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=q8iywBvR6aXXlWQwQqGHS5ZddSd084RDcegjXYLHebk=; b=O8sPfCVB3lAlQDxYi8ggqMb8XJsOI4dS+/0rkMCk7jtL4qOpaDDS3mQedl1oYZESr1 iTANe2AJzvpsu9vt/l9Ry3jA9jQu+HS+6TptHVeZ+beEazkj06xqfwuxKayF+T+NXCDE V1VVxuyISxROIvvS+hRYx15EWEjkFpps41LYmwvFfs56wXOgMwStiBbUQ8ySt9iFNB+N 4eWSo++NT7ZqNZx3Z4mAvKCs6ciUsRqL+/4XiUmv6vwTt1VLClmiRlb8//3aUu6DglwZ 1cw7ICi8ezabFZ9YOGeiuWAdHc53mucui5H6G96cdbH7xrJyhMMza9BZkJe5ULrZIJ22 kn9w== X-Gm-Message-State: ALoCoQnOrrqcfQsBCGy5+BFyf7M8pPzLE7b2lEeaoyPOQQSB6bexnWkxwIbVfbmDpElxX1T8zvEL X-Received: by 10.68.131.97 with SMTP id ol1mr3130266pbb.4.1386973600812; Fri, 13 Dec 2013 14:26:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.132.164 with SMTP id ov4ls1174774qeb.32.gmail; Fri, 13 Dec 2013 14:26:40 -0800 (PST) X-Received: by 10.52.157.38 with SMTP id wj6mr1816432vdb.63.1386973600646; Fri, 13 Dec 2013 14:26:40 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id pt3si1196481vec.70.2013.12.13.14.26.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 14:26:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id p14so112851vbm.14 for ; Fri, 13 Dec 2013 14:26:40 -0800 (PST) X-Received: by 10.220.124.68 with SMTP id t4mr2224004vcr.52.1386973600584; Fri, 13 Dec 2013 14:26:40 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp73480vcz; Fri, 13 Dec 2013 14:26:40 -0800 (PST) X-Received: by 10.66.191.162 with SMTP id gz2mr5808339pac.151.1386973599818; Fri, 13 Dec 2013 14:26:39 -0800 (PST) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id am2si2519208pad.38.2013.12.13.14.26.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 14:26:39 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id kl14so593976pab.37 for ; Fri, 13 Dec 2013 14:26:39 -0800 (PST) X-Received: by 10.68.65.168 with SMTP id y8mr5913152pbs.89.1386973599396; Fri, 13 Dec 2013 14:26:39 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id qz9sm7457908pbc.3.2013.12.13.14.26.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 14:26:38 -0800 (PST) From: John Stultz To: LKML Cc: Greg KH , Android Kernel Team , Sumit Semwal , Jesse Barker , Colin Cross , Olav Haugan , John Stultz Subject: [PATCH 022/115] gpu: ion: IOCTL return success when error occurs Date: Fri, 13 Dec 2013 14:23:56 -0800 Message-Id: <1386973529-4884-23-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1386973529-4884-1-git-send-email-john.stultz@linaro.org> References: <1386973529-4884-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Olav Haugan ION_IOC_MAP, ION_IOC_SHARE, and ION_IOC_IMPORT may return success when an error occurs. Add correct error handling to ION_IOC_MAP, ION_IOC_SHARE, and ION_IOC_IMPORT. Signed-off-by: Olav Haugan [jstultz: modified patch to apply to staging directory] Signed-off-by: John Stultz --- drivers/staging/android/ion/ion.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index f536ce5..a054edd 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1040,20 +1040,27 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) data.fd = ion_share_dma_buf(client, data.handle); if (copy_to_user((void __user *)arg, &data, sizeof(data))) return -EFAULT; + if (data.fd < 0) + return data.fd; break; } case ION_IOC_IMPORT: { struct ion_fd_data data; + int ret = 0; if (copy_from_user(&data, (void __user *)arg, sizeof(struct ion_fd_data))) return -EFAULT; data.handle = ion_import_dma_buf(client, data.fd); - if (IS_ERR(data.handle)) + if (IS_ERR(data.handle)) { + ret = PTR_ERR(data.handle); data.handle = NULL; + } if (copy_to_user((void __user *)arg, &data, sizeof(struct ion_fd_data))) return -EFAULT; + if (ret < 0) + return ret; break; } case ION_IOC_SYNC: