From patchwork Thu Jul 25 02:09:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuhong Yuan X-Patchwork-Id: 11062301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8503613A0 for ; Sat, 27 Jul 2019 06:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72C40289BE for ; Sat, 27 Jul 2019 06:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66CFA28B68; Sat, 27 Jul 2019 06:45:27 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 C97E0289BE for ; Sat, 27 Jul 2019 06:45:26 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DD5582054; Sat, 27 Jul 2019 08:44:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DD5582054 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1564209924; bh=586BzHfd8jQoqbLIzkeaccF2JS4qCOSvqdtfadGM30k=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=eyAerLSxG8dNZ2gGnOg3XAx+9zAvd7kC+qVyhsShRhIlXzqUc0Cx84N0GpRr1Naeb Y9uU9qMp6G8VM9awJPgfc1VL1Oe9SEQa9VV4xgVOH1kFDDIV/qy25GrY4iAWRcpkux snaRBn4k/aJS+gUUvII22Ya/ScTWmLqtHeboNq6k= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 589FCF80447; Sat, 27 Jul 2019 08:43:41 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09F69F803D0; Thu, 25 Jul 2019 04:09:35 +0200 (CEST) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4EB7CF800E8 for ; Thu, 25 Jul 2019 04:09:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4EB7CF800E8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OS7tR5zy" Received: by mail-pf1-x442.google.com with SMTP id r1so21860842pfq.12 for ; Wed, 24 Jul 2019 19:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=r6xcP5bA0sOT1XKD434f1tzHJ1w8Z5pUhBurvR0md3Y=; b=OS7tR5zyV52UK8u0O/4vWdCPtirPj+DX3kR5Qgo2YISvEdfPqAmP6f7NJy+3klPmT4 RfiJkeso73KofXRUuat2uX68lTB2nU+lTIoDsvW+XXbqveTSN22AxhIXfvTl1OPmEGOX DH3L7/9/XwY5TeTaDs6ABHYUM5FB1G0P87Pr1+h/ZEgE/aGHr9TSGUmLgFDYzYzqlESP 1iAG/50feaU5Wpnt7JFSAudk6bjOxCwMgQE2p0Aw+aNMQHkFGspQpD8Jd1B6o/qaNIi6 T5cdmRleLEqVXZqLsvnAhx+nQAuZlQQO0MSsTDOGkl5s4M6GF7nA2xY1Q2icg/YVFy96 pCIQ== 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:mime-version :content-transfer-encoding; bh=r6xcP5bA0sOT1XKD434f1tzHJ1w8Z5pUhBurvR0md3Y=; b=W/6wwfqHT6uVi7ZBCN4GIp21CyuEkK3ulxnbdtkdLkfKTowSjxPb5XkF+54XK49m6x lBW0GicwgeXNoSKuaK2Aeu+bdvkKiHr/yz8P8cTGO8mQxznl+xLTgkrqMpATy5UPi/+s mZe0pyb6qI078eacVmhOpMrfYUyf0FO4pUpsnFpm5t52wE9OI+12lzRNZp/wzelQ8Vwl hLjnfeT5Jr9OdT3jb0IwGtAD6Rtwq6MSLFfA+BeStAhjSn55chxSjQV67d19t9QFKEBc cXB78tYkej4bUiBPespnwQ+MdhmN/vFmCyxJIZrUpnZctmYgtxZmIUENbjOciQGsqntw P4hg== X-Gm-Message-State: APjAAAXizykSNyilRuwVrE6u2l0OfE+nWGGujCX1AJzQfD8kFzC28PAD baumohb+TofGjT1gE62TcRM= X-Google-Smtp-Source: APXvYqy09Mds/SHzIx9nVdnz1Mx3LWHtzspmtN58tOrZhoceS+OUaqb+iSoiBuk9HxtsEaV20c2MbQ== X-Received: by 2002:a17:90a:2430:: with SMTP id h45mr92683720pje.14.1564020569953; Wed, 24 Jul 2019 19:09:29 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id q1sm56990685pfg.84.2019.07.24.19.09.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 19:09:29 -0700 (PDT) From: Chuhong Yuan To: Date: Thu, 25 Jul 2019 10:09:24 +0800 Message-Id: <20190725020924.7643-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 27 Jul 2019 08:43:36 +0200 Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Chuhong Yuan , Takashi Iwai Subject: [alsa-devel] [PATCH] ALSA: echoaudio: Replace kmalloc + memcpy with kmemdup X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of using kmalloc + memcpy, use kmemdup to simplify the code. Signed-off-by: Chuhong Yuan --- sound/pci/echoaudio/echoaudio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index b612a536a5a1..ca9125726be2 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -2189,11 +2189,10 @@ static int snd_echo_resume(struct device *dev) u32 pipe_alloc_mask; int err; - commpage_bak = kmalloc(sizeof(*commpage), GFP_KERNEL); + commpage = chip->comm_page; + commpage_bak = kmemdup(commpage, sizeof(*commpage), GFP_KERNEL); if (commpage_bak == NULL) return -ENOMEM; - commpage = chip->comm_page; - memcpy(commpage_bak, commpage, sizeof(*commpage)); err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); if (err < 0) {