From patchwork Tue Sep 18 15:30:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhong jiang X-Patchwork-Id: 10604513 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 7CCF5112B for ; Tue, 18 Sep 2018 15:42:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9591328986 for ; Tue, 18 Sep 2018 15:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90C3D288C5; Tue, 18 Sep 2018 15:42:58 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 362B32BBEB for ; Tue, 18 Sep 2018 15:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729753AbeIRVQC (ORCPT ); Tue, 18 Sep 2018 17:16:02 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59090 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728912AbeIRVQC (ORCPT ); Tue, 18 Sep 2018 17:16:02 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A7D4172264A2F; Tue, 18 Sep 2018 23:42:49 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.399.0; Tue, 18 Sep 2018 23:42:47 +0800 From: zhong jiang To: CC: , , , Subject: [PATCH] media: dvb-frontends: Use kmemdup instead of duplicating its function Date: Tue, 18 Sep 2018 23:30:28 +0800 Message-ID: <1537284628-62020-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP kmemdup has implemented the function that kmalloc() + memcpy(). We prefer to kmemdup rather than code opened implementation. Signed-off-by: zhong jiang --- drivers/media/dvb-frontends/lgdt3306a.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c index 0e1f5da..abec2e5 100644 --- a/drivers/media/dvb-frontends/lgdt3306a.c +++ b/drivers/media/dvb-frontends/lgdt3306a.c @@ -2205,15 +2205,13 @@ static int lgdt3306a_probe(struct i2c_client *client, struct dvb_frontend *fe; int ret; - config = kzalloc(sizeof(struct lgdt3306a_config), GFP_KERNEL); + onfig = kmemdup(client->dev.platform_data, + sizeof(struct lgdt3306a_config), GFP_KERNEL); if (config == NULL) { ret = -ENOMEM; goto fail; } - memcpy(config, client->dev.platform_data, - sizeof(struct lgdt3306a_config)); - config->i2c_addr = client->addr; fe = lgdt3306a_attach(config, client->adapter); if (fe == NULL) {