From patchwork Fri Dec 23 19:51:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Saini X-Patchwork-Id: 9495171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9CDF9606A9 for ; Tue, 3 Jan 2017 16:14:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C86F27B81 for ; Tue, 3 Jan 2017 16:14:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7180427BFC; Tue, 3 Jan 2017 16:14:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2745727B81 for ; Tue, 3 Jan 2017 16:14:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7B7E6E5E9; Tue, 3 Jan 2017 16:14:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 762376E13B for ; Fri, 23 Dec 2016 19:51:32 +0000 (UTC) Received: by mail-pg0-x244.google.com with SMTP id b1so1426569pgc.1 for ; Fri, 23 Dec 2016 11:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uTsZYb9P0p636p/RsTSn7nFDOyvuvUZv7C9TVQ8M9NM=; b=XmC0lsCM6P+KzVAknKlucmcKqwVYJGTOaYFSwFY7D+HCSM3Vhhw2o5qEiGHSXBjrmZ 2UN2ul1OvkQwg1p6NhQIK327rAb7o+hUePIGkS8GjcaGapPCunoaKqiO7bwL6/uwkV5z 5pZHWHQr3+/MveKBAYx4LJwyOPC8v9QlwgeRUb82kInvR3xUJH1pytDylJZIF5HQ/RDF 43EgmOaQwLLkNeiGvTquu0s5kediWWChbI6CTL4GCLQ7Q8jc8ttmg9D53JSTsBGahrSr evmdEr4uxFVWoB5kw6YqFcXp3Ojs9VMDFZ45deWPwYgAsHlAmLnWxp/5k3FTuRmbCtoB 7c+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uTsZYb9P0p636p/RsTSn7nFDOyvuvUZv7C9TVQ8M9NM=; b=c7duOxERRTHUGkEEvrYD0OGUaCIY1T9Hl1ECzP1iYSIPaAvS3nSuCRzp6Iud594ign icdlJrIMDwOnktjb6UAQF8y5ce8kmDZ67TxH8xnU+07Zy0fd+8oKSwdItbs9DmFRpPxz KnM7b9flF+UGdQ3HRxB08ScFmrBWhFXHGQF1DZVolmgWKLkNCfH3XBg9rr3iP0OpGxJg J0+PcJa8yAn9jTjYxnTU1Qt1geFlCV5IWnVdDiDFUAtZI9Cjl13VCuXJWyFtGJS7kUZE AZVUNYjVJsPIByZCjlwAwqR+pAA37o0hzmhGNawIqCtemk6DNM/wEtoWALnnOqwAuXKv mXsA== X-Gm-Message-State: AIkVDXL+ouWR28dT2jTDxGl8FcFkSDB986EEy8nwNCIMwPRU2u6cb/rUmplJPilsWAmmqQ== X-Received: by 10.98.93.201 with SMTP id n70mr15290398pfj.161.1482522691670; Fri, 23 Dec 2016 11:51:31 -0800 (PST) Received: from localhost.localdomain ([103.61.255.51]) by smtp.gmail.com with ESMTPSA id m69sm6688596pfj.34.2016.12.23.11.51.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Dec 2016 11:51:31 -0800 (PST) From: Shyam Saini To: syeh@vmware.com Subject: [PATCH] gpu: drm: vmwgfx: Use kmemdup instead of kmalloc and memcpy Date: Sat, 24 Dec 2016 01:21:10 +0530 Message-Id: <1482522670-3229-1-git-send-email-mayhs11saini@gmail.com> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Tue, 03 Jan 2017 16:03:01 +0000 Cc: thellstrom@vmware.com, linux-graphics-maintainer@vmware.com, Shyam Saini , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When some other buffer is immediately copied into allocated region. Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. Signed-off-by: Shyam Saini --- drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c index b6126a5..941bcfd 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c @@ -319,18 +319,17 @@ int vmw_otables_setup(struct vmw_private *dev_priv) int ret; if (dev_priv->has_dx) { - *otables = kmalloc(sizeof(dx_tables), GFP_KERNEL); + *otables = kmemdup(dx_tables, sizeof(dx_tables), GFP_KERNEL); if (*otables == NULL) return -ENOMEM; - memcpy(*otables, dx_tables, sizeof(dx_tables)); dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables); } else { - *otables = kmalloc(sizeof(pre_dx_tables), GFP_KERNEL); + *otables = kmemdup(pre_dx_tables, sizeof(pre_dx_tables), + GFP_KERNEL); if (*otables == NULL) return -ENOMEM; - memcpy(*otables, pre_dx_tables, sizeof(pre_dx_tables)); dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables); }