From patchwork Thu May 19 14:08:33 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: 9127703 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 0C5DC60467 for ; Thu, 19 May 2016 14:09:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3935F281DF for ; Thu, 19 May 2016 14:09:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06C5B281FB; Thu, 19 May 2016 14:09:37 +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 9BF5B281B9 for ; Thu, 19 May 2016 14:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755107AbcESOI5 (ORCPT ); Thu, 19 May 2016 10:08:57 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36583 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755114AbcESOIy (ORCPT ); Thu, 19 May 2016 10:08:54 -0400 Received: by mail-pf0-f193.google.com with SMTP id g132so8290311pfb.3; Thu, 19 May 2016 07:08:54 -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:in-reply-to:references; bh=z4Yfa6LKdjP3GZJxzZaEPLuM0hUSRoR7KnQPgiandpA=; b=Zsae4hGhRQy8N97/A4CtwDFY3R5fPmDQTpjbZJYwpVs/WGrN0D7vOABPmAcAVogLfM Sbj+wEQT4Ja6Lm6k6w8Tpv9fzJUtOL2X8Nm6SWd0pX/ouIkTu3+IAvWWD4WjsRLnoDo7 G+COUZrGGXuswMCOuu37GU6KNo1WCAaC58Mu8p9vpDt5n+NVvyODoQKxjRg9Oy2YvuoW vek1aCSEPSgP/uwGaEIVBWlsebadxkqSjPpnoSRRMG5ueLfHNVM/VTJ84fu62ujdKENE QDoFmEKnKdg1Q1pWVLFE1AN733+7Lc4ZO2JdJLAi7EDgf1wa3/J3++nWnfTCeBkKkbMA I8gA== 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:in-reply-to :references; bh=z4Yfa6LKdjP3GZJxzZaEPLuM0hUSRoR7KnQPgiandpA=; b=cQfthtpFM5YU60kU68ihi+EmYI5u1kfyedwm4aFaQPs6Zop8dN+aF2irKC7u2F6RF3 NyT89G+T/IKX1uMi+SFD1tOj8FivnVWiSkDn7ecpAipu2sr9NVgObSW9y3MnC8Jz+j6+ VyIYxSs4NXtliRQuoyb3sr6LwuA9uHodR67eX1pA2ZQRiCzmXknuFpGNV3XvHFcwtcWh 5yiP/BZnWB3OeVfk4Gshk1RTS1tOcc3XFd8c1sLSLz4+yNMrZ3DaVdcR8gOcJ69IL7ck DU21HTdeCU+A8DvkiSmTp0BrBdHRLQO8QehTXjp+yi0/EjTATOMsQtM8iVgOMPd+FmHE lBIg== X-Gm-Message-State: AOPr4FWBePWcULbzxbnoS2A+jw+ysaaozZABn+cxmxPkkRvkT9aXvgWSvH7CJS6XMg+JGA== X-Received: by 10.98.89.71 with SMTP id n68mr20267464pfb.82.1463666933678; Thu, 19 May 2016 07:08:53 -0700 (PDT) Received: from kp.domain.name ([110.235.28.83]) by smtp.gmail.com with ESMTPSA id ey12sm20317959pac.26.2016.05.19.07.08.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 May 2016 07:08:53 -0700 (PDT) From: Muhammad Falak R Wani To: Hannes Reinecke Cc: Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [SCSI] aacraid: use kmemdup Date: Thu, 19 May 2016 19:38:33 +0530 Message-Id: <1463666915-16906-3-git-send-email-falakreyaz@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463666915-16906-1-git-send-email-falakreyaz@gmail.com> References: <1463666915-16906-1-git-send-email-falakreyaz@gmail.com> 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 Reviewed-by: Raghava Aditya Renukunta --- drivers/scsi/aacraid/commctrl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 4b3bb52..b381b37 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) } } else { struct user_sgmap* usg; - usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) - + sizeof(struct sgmap), GFP_KERNEL); + usg = kmemdup(upsg, + actual_fibsize - sizeof(struct aac_srb) + + sizeof(struct sgmap), GFP_KERNEL); if (!usg) { dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); rcode = -ENOMEM; goto cleanup; } - memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) - + sizeof(struct sgmap)); actual_fibsize = actual_fibsize64; for (i = 0; i < usg->count; i++) {