From patchwork Wed Sep 3 20:32:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 4837051 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 827D8C0338 for ; Wed, 3 Sep 2014 20:33:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71DD320211 for ; Wed, 3 Sep 2014 20:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 744F920148 for ; Wed, 3 Sep 2014 20:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755992AbaICUd1 (ORCPT ); Wed, 3 Sep 2014 16:33:27 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:44268 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750761AbaICUd1 (ORCPT ); Wed, 3 Sep 2014 16:33:27 -0400 Received: from 200-100-75-232.dial-up.telesp.net.br ([200.100.75.232] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPHF6-0000LE-Pg; Wed, 03 Sep 2014 20:33:25 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1XPHF1-0001H2-6u; Wed, 03 Sep 2014 17:33:19 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil Subject: [PATCH 04/46] [media] vivid-vid-out: use memdup_user() Date: Wed, 3 Sep 2014 17:32:36 -0300 Message-Id: <8e3336dbdbd26a56fb6817a4dc7cb31d860e8c5d.1409775488.git.m.chehab@samsung.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of allocating and coping from __user, do it using one atomic call. That makes the code simpler. Also, Found by coccinelle. Signed-off-by: Mauro Carvalho Chehab Acked-by: Hans Verkuil diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c index c983461f29d5..8ed9f6d9f505 100644 --- a/drivers/media/platform/vivid/vivid-vid-out.c +++ b/drivers/media/platform/vivid/vivid-vid-out.c @@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv, return ret; if (win->bitmap) { - new_bitmap = kzalloc(bitmap_size, GFP_KERNEL); + new_bitmap = memdup_user(win->bitmap, bitmap_size); - if (new_bitmap == NULL) - return -ENOMEM; - if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) { - kfree(new_bitmap); - return -EFAULT; - } + if (IS_ERR(new_bitmap)) + return PTR_ERR(new_bitmap); } dev->overlay_out_top = win->w.top;