From patchwork Thu May 19 13:50:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Falak R Wani X-Patchwork-Id: 9127655 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 B5E9860467 for ; Thu, 19 May 2016 13:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A99E9281BE for ; Thu, 19 May 2016 13:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E189281C6; Thu, 19 May 2016 13:51:21 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 3B918281BE for ; Thu, 19 May 2016 13:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754980AbcESNvD (ORCPT ); Thu, 19 May 2016 09:51:03 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36850 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754871AbcESNvC (ORCPT ); Thu, 19 May 2016 09:51:02 -0400 Received: by mail-pf0-f196.google.com with SMTP id g132so8247651pfb.3; Thu, 19 May 2016 06:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=wV9enfNojZCq+Ohdp/SxsMO3shdBSLrU19+dBvYjdCY=; b=Bgf/f/BABUpgt/ZVsoxZGb5NQoiB0XWjfuKHDNZUvCPg7HvqfFCnlGGsGNHu4788UG 5RAdWo56btD+ycAtoTYChEHLuazOl1F7CilFNGXe8Gf7b+lvyOzFTs1sFl6PEosvqT8g 8juVVWPeVYE1EQpm+07eiaaKetj/LcQ2n2MuTzE0AYwo8dJvrMa/oT8srR+3e8SoKx33 +iHtJQHYbuVEUTyATWUHMOJigfo19Tw4czrPd2RHvA6BivZa5PMgRm4KFQRKJqO8Ung8 2tFNedw/6TYQF3XAEfTPiI7dFIUKGLNIsdEKTZ03k7g6QiQ8utSfgE3db49dZMZnG1lJ EhtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wV9enfNojZCq+Ohdp/SxsMO3shdBSLrU19+dBvYjdCY=; b=k6Hfx4oBVC9KFlXhptEYH+uTBGd32rGATezfiKXDQZUCPoFjxSZtUhPLCabsimL4qN WK3fcG1gNBKa2paU/4esQW+IjUOeUOZNp5Svp6Mq8t4VKlYINJqCuR+7QBbboE8rZpJr tNp8OHrU/ohtEI+YqAlNDmJvVqDOB9Uz8nWAi6XDlxWGcnQ6/qNlMlCBJjhaCcw+d9GX jecc7XOaNh1Mo6tW+1CaiPaEGNd//Kt41PcfBEaLcdz3JWyLpysokMthh3cr34Ai7ONd /ERAQRdeSdGBFdmBk6G/vZsDFiC07hnFMTQseRTqX+lodfjwitDmxs37P3j+8JBTNXHZ DgyA== X-Gm-Message-State: AOPr4FUVzN2y71rdzwoGy6be4S4PuN3zi5g0WihmALLEFKHtFONeWxi0Y52bTpbTHWrXew== X-Received: by 10.98.20.78 with SMTP id 75mr6539049pfu.5.1463665861065; Thu, 19 May 2016 06:51:01 -0700 (PDT) Received: from kp.domain.name ([110.235.28.83]) by smtp.gmail.com with ESMTPSA id z63sm20187258pfb.47.2016.05.19.06.50.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 May 2016 06:51:00 -0700 (PDT) From: Muhammad Falak R Wani To: Sathya Prakash Cc: Chaitra P B , Suganath Prabu Subramani , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mptbase: use kmemdup Date: Thu, 19 May 2016 19:20:47 +0530 Message-Id: <1463665851-16334-1-git-send-email-falakreyaz@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup. Signed-off-by: Muhammad Falak R Wani --- drivers/message/fusion/mptbase.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 5537f8d..4cad96e 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -5997,13 +5997,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc) if (mpt_config(ioc, &cfg) != 0) goto out; - mem = kmalloc(iocpage2sz, GFP_KERNEL); + mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL); if (!mem) { rc = -ENOMEM; goto out; } - memcpy(mem, (u8 *)pIoc2, iocpage2sz); ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem; mpt_read_ioc_pg_3(ioc);