Received: by 10.223.164.202 with SMTP id h10csp636835wrb; Wed, 22 Nov 2017 12:48:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMb6OeJ2H5SKLXCDoGYuE7KMSIUN7ObuqxbyZITxURThL5LhXp4LaHP6LrPNOJRxGiaNfWVc X-Received: by 10.84.217.150 with SMTP id p22mr11079434pli.427.1511383715883; Wed, 22 Nov 2017 12:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511383715; cv=none; d=google.com; s=arc-20160816; b=PVNnZtEZrFKZkkymSYCnwDuzU/Mq/YNTod0/xqu2rHiBNooishgxF2XQM4d4gU5PhZ qjKNeGmd9orKa+ZOc8PQkkBOC+rJ6Z92IHu8lO6S3LHuO+lWxmxB9vGid8k9ZkmMcQPl rhZ5BQD14Jfb6e4fSN6lZwRcprGd2NlS56bcpUPq7KqxzNLkOpwyDdPigrWMmB90Rnj5 TgXCiY9/oYHIqCzkcMfFmquVs4WvNpHePO3dvioR4f79jBzgOLs7CnC9gHHFL0hafx4Q QyLoNwBU+hbgssFMu3VrWH9Pj2KquuNBXcf1dW0oRC3+ByItfGpPG5VgcNVJZ3HzisDU mZpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=Yto1vpHONkhb4Phs9ej8DuH7Do8HH/orxo/mXTOfIiQ=; b=hkuaYt0h5MJfJojSrSNKPuzIsedtJVKyl2msXTjUs8gofbxp3djkVChXIXbyeC5uhr pW8CDjPcP78xgNMjOnQvxFm1yxHZnQ7lusJ6XwV7fIDy2I31VfLVqt/jqk3X39R/XoAv 3OV4rzrX9U2dbg31aWUTUvNL19KwXTARH5giaCptu2dyHjXLISGbDKx1aBP/qrcRYRT4 qbCYJqHX6NgWuYWEXMbyskLGk5Xs7Hzk+uj+dKlU2uAQtvnBwmxg6jJFqEadt3Nx0wub tO5668/FbYQVxggrbWFzJToDYzRS3WpQSKxoiD+QXzKxz1wN4WdAmlAyVSPBVSUYiPgm Lfhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JMVFc9PG; 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=pass (p=NONE sp=NONE 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 f9si14299053plo.763.2017.11.22.12.48.23; Wed, 22 Nov 2017 12:48:35 -0800 (PST) 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=pass header.i=@gmail.com header.s=20161025 header.b=JMVFc9PG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751507AbdKVUqQ (ORCPT + 77 others); Wed, 22 Nov 2017 15:46:16 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:46407 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751324AbdKVUqP (ORCPT ); Wed, 22 Nov 2017 15:46:15 -0500 Received: by mail-io0-f196.google.com with SMTP id q64so11677061iof.13 for ; Wed, 22 Nov 2017 12:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Yto1vpHONkhb4Phs9ej8DuH7Do8HH/orxo/mXTOfIiQ=; b=JMVFc9PGSDpHIwnv53jq3T1gUZ4s6e/4mysKoSRII91hsDAXbU/8o8o3HplcWCUuj4 O5I7o0tFwVyy6OU19frBQ7PZO7Eq7NXbIWlPmeD/Ris4RGsOSMTWyg1bCr5y87ecoQz/ XmDv3al7P11qXeUQAtykoMZ0YAIqpGzjNeU/+sd1RLBbyvYqNS/kond093bPr+wp2SCx /eNf462CW5ESkXwv+o7B8w4H0s463dcOMedoVFTExbZxTGUiOCtDlhmLc4mWsw8QNvHu b1SikWFFR2Gb34wfn74gL/lY8RuGsME3UVZU3s6uWH3erQDT9TAnGCX5n/C+dtbI/IcM t+hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Yto1vpHONkhb4Phs9ej8DuH7Do8HH/orxo/mXTOfIiQ=; b=iHPv/CEo7qN5ooxr3h4dR4mVy4T5GRPN4OTflXInVaOSijQLH4d9W+eOzzC+rLvS8T 1LW+NfYpTj/D+kLtUEfQ0zNJlELa9JwB7bx8PTe7rVh88rKcljbbIsjSqpedQY47CEVD ETNh932b2/qMtxteT31kBhwHwAfOwXbBiWWdES+7sEiFKIBglwwk/eZ42joFqh7hyC/7 hyfG7AXSsFqzj9xrl0qQFCwDqYly3W+ukrUC8LfxC5APyEaszf5pL7Jr/3qlpgto9X8H YpPhoKT2VdyhbB2SD4Gna4zZu5G2gNcVzebnaZkQ8twcGAzTsxYv+wVAweSsusiTQ4j6 CqFA== X-Gm-Message-State: AJaThX5Nv1B2MRLaO63HKjpObKK+HxW2sYjMIV0gAxA59pYHwSbt/voK zbhMCIDNHlWXaxA73l4bv49e5gzEc8ntkE8B8NL5yiG+ X-Received: by 10.107.24.135 with SMTP id 129mr23877980ioy.79.1511383574715; Wed, 22 Nov 2017 12:46:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.71.68 with HTTP; Wed, 22 Nov 2017 12:46:14 -0800 (PST) In-Reply-To: <1511366141.6989.89.camel@perches.com> References: <1511364547-18418-1-git-send-email-gomonovych@gmail.com> <1511366141.6989.89.camel@perches.com> From: "Gomonovych, Vasyl" Date: Wed, 22 Nov 2017 21:46:14 +0100 Message-ID: Subject: Re: [PATCH] VMCI: Use memdup_user() as a cleanup To: Joe Perches Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I am agree, I will change it. On Wed, Nov 22, 2017 at 4:55 PM, Joe Perches wrote: > On Wed, 2017-11-22 at 16:29 +0100, Vasyl Gomonovych wrote: >> Fix coccicheck warning which recommends to use memdup_user(): >> drivers/misc/vmw_vmci/vmci_host.c:757:11-18: WARNING opportunity for mem= dup_user >> Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci > > Nice little cleanup. > >> diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers/misc/vmw_vmci/v= mci_host.c > [] >> @@ -754,18 +754,12 @@ static int vmci_host_do_ctx_set_cpt_state(struct v= mci_host_dev *vmci_host_dev, > [] >> + cpt_buf =3D memdup_user((void __user *)(uintptr_t)set_info.cpt_buf= , >> + set_info.buf_size); >> + if (IS_ERR(cpt_buf)) { >> + vmci_ioctl_err("cannot allocate memory to set cpt state (t= ype=3D%d)\n", >> + set_info.cpt_type); >> + return PTR_ERR(cpt_buf); > > Trivia: > > The vmci_ioctl_err might not be necessary. > There is a dump_stack() on allocation failure. > > and > >> @@ -774,7 +768,6 @@ static int vmci_host_do_ctx_set_cpt_state(struct vmc= i_host_dev *vmci_host_dev, >> >> retval =3D copy_to_user(uptr, &set_info, sizeof(set_info)) ? -EFAU= LT : 0; >> >> -out: >> kfree(cpt_buf); >> return retval; > > Perhaps move the kfree above the copy_to_user, > remove the retval declaration and use > > return copy_to_user(uptr, &set_info, sizeof(set_info)) ? -EFAULT = : 0; > --=20 =D0=94=D0=BE=D0=B1=D1=80=D0=BE=D1=97 =D0=B2=D0=B0=D0=BC =D0=BF=D0=BE=D1=80= =D0=B8 =D0=B4=D0=BD=D1=8F. From 1584782322614304175@xxx Wed Nov 22 15:56:38 +0000 2017 X-GM-THRID: 1584780783794426773 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread