Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1105272ybi; Wed, 3 Jul 2019 09:34:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfjlAyQrYN0LdRrxpE5WGsp9Ic8QS9c7aWV43wfUh97BXOhmpRmjPXM8f2yKVjGLtbe18J X-Received: by 2002:a17:902:16f:: with SMTP id 102mr41797857plb.94.1562171661223; Wed, 03 Jul 2019 09:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562171661; cv=none; d=google.com; s=arc-20160816; b=q0vEgXY3BTEY0M3dRJ6GsDmVnzHy5N9AvW9Tk12G8Ggg2/iVGTuig8ychY8cdu8mp3 ynsbEKw4hCvKWOxkyd7KO1PWYyjKwKH5C473SN4R90CFm25IGOmiPlf5c/XmLN/k4j6v LIWhc47x7vlkGg+vHC74Ed4XutHzv7/YEhWNA6MHr0o06oK6oalNOSOHHzKJeWAPp+SQ tl0HO62qWCXxjkq+IGlPUDR10n6Nr0TXVkcz6xnNlncGnQVG/W5m3LH9kBbjKQ0OAxpK ZHLkg2e78VDSTc30eDzRx0XnTNGUz4KrRc1GVGWvA/cnbam5aqZmzzbUAwSQ+K4JZu9g 044g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=MCqMV61NT0BMmX6Fho6eWqPzt3K0aDZuWTbDCpVsXg4=; b=K70zf69VsYy4LRKR3e0PgoZ1wh504Egrsd6kP99yutThLAv+iYxnsKWg7BqGy0wNHG v318KmDkd6lWE2bWsIKKWwnlzYuHwgNWjWAkqftybCXEsBHPmmTFz/TaZjNhOpYd63yo ySmDIYYNct7ycVR/BOYKXL5D2OoY5ovMNDemzCUuCHtkq0ESy1INGRLZi8ADlxuxC4rQ Cy2TS86E7KEYjpsfkjEfxWROno8YPZu97sT5IzJlFHkSPrIuiKw6v6y24LDLxI0Wym1y jIJuZmgkdOkrZ7d2Vwxk2TZ5G5JJQG8kkR5qyVGV6YHyUWuJ+ooV/6wGZx10CrX8DG53 Y4ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=vJUvklVE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b73si2407514pjc.53.2019.07.03.09.34.06; Wed, 03 Jul 2019 09:34:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=vJUvklVE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727103AbfGCQcT (ORCPT + 99 others); Wed, 3 Jul 2019 12:32:19 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40642 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbfGCQcT (ORCPT ); Wed, 3 Jul 2019 12:32:19 -0400 Received: by mail-pg1-f195.google.com with SMTP id w10so1507719pgj.7 for ; Wed, 03 Jul 2019 09:32:18 -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; bh=MCqMV61NT0BMmX6Fho6eWqPzt3K0aDZuWTbDCpVsXg4=; b=vJUvklVEWOje9plOQWmkgMd6LPxQbDPJiXUs7nd/tN99P4Fgce3N04lgxpoh2kvBde 2Fwgt6TDdRpNjRxC2bNiJAn+mldjNvG8EoYiYLY88avJySuQiMuiV5e+52EbkBjbWqos iLdsSmcjump8t6f/u/yZJgTN4cIGxTWqIztSWthJTNriyvvAqwg6/zXwqE7z4/TJD7bU 9tdy+9+WNRlojHWJBg/1F/BfaCDM0UGmvQ2h10e/p0SGrP/dWOQVEwu6gFRb80mfF8nJ ta+djES2kNC9DWqi9irBzFZmndX5aiu1AEIm4aXIt8Q+3c8HYlZby/pun8LKo0bXC2a6 QI6g== 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=MCqMV61NT0BMmX6Fho6eWqPzt3K0aDZuWTbDCpVsXg4=; b=O77O8fswlP3bB/EG1IE7/OtrkGzKjEGxOnTZOJzZPRcFeAXVI8dOIWtNQezuHp2rly X1Z0NO4cklZvEcoHbQY5IoPaGJ70RzwwkfWSTPWxts9GTTB+Nls7mN8NgDSw+NVV/p2S 6pCfrn2OI9txAvZ7VF/mPxa1OVLKiqOhBl77TYfHbvr3uwVIoCrldY/9hVtEqklCH+3w QdO6neF7lAB92lJTEAmcwP6nyltbxLPwKn9MqOydhU3MIXypHzwzrTqu8qM0eswWY1xd /LwMOxPltBSlx5LrObeuLjyex7mrFf3157HYLW1F4SG+wZgedgiH7XPrvabpS2XVpiDg MnGQ== X-Gm-Message-State: APjAAAUCvWGwpx7Eq/IdrwiOibigt8/5FJEdhajJ4oBVkVuOlTIvmG32 11VPQMtdxEUXib3reuxBZ58= X-Received: by 2002:a17:90b:8cd:: with SMTP id ds13mr13034487pjb.141.1562171538615; Wed, 03 Jul 2019 09:32:18 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id o12sm2270041pjr.22.2019.07.03.09.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2019 09:32:18 -0700 (PDT) From: Fuqian Huang Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH v2 33/35] sound/pci: Use kmemdup rather than duplicating its implementation Date: Thu, 4 Jul 2019 00:32:10 +0800 Message-Id: <20190703163210.983-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup is introduced to duplicate a region of memory in a neat way. Rather than kmalloc/kzalloc + memcpy, which the programmer needs to write the size twice (sometimes lead to mistakes), kmemdup improves readability, leads to smaller code and also reduce the chances of mistakes. Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy. Signed-off-by: Fuqian Huang --- Changes in v2: - Fix a typo in commit message (memset -> memcpy) sound/pci/echoaudio/echoaudio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index b612a536a5a1..35bd3e7c8ce1 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_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) { -- 2.11.0