Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1769031rwd; Mon, 15 May 2023 02:47:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ga2ps6zpCCI1hAHqXiQV396nlQ/Z9RHugXYLOYbpfS31Tzx3+ws0clBm2aFWCGqFowwzD X-Received: by 2002:a17:90a:db8e:b0:250:83ef:a038 with SMTP id h14-20020a17090adb8e00b0025083efa038mr31596023pjv.8.1684144078693; Mon, 15 May 2023 02:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684144078; cv=none; d=google.com; s=arc-20160816; b=W25Xjdtmc3nkwZos3odtU75XZEyZi9JGSBL0ZdNjsvh3cwF62Qxm6w+vX2HmfOjwy4 ZWe2W9xaX5ikHZo8yNQl1Bp+eca+6exPGZX81nR5uIUW5tdypt1OZbVu4dYT2WmPgN3D RsBvMZ4AYI0PDSbwdlOTNeTlOdU4m7FcK6922NC6KWiMG8ewRoiB1R2rzwUu38tT3YmV 8SmNNu9gWCmpGW5ZrQisROuDFq54Tdu4tXms8EfUBU+/Lle6ViySKeWelc846Vjcrq3X a2BAMGXO9Tet2oRFmJ5oUqv8Ikid3Eexlv06pUghn4tBXhmVtjMi8jjSYKdYZfty2zTB Y54g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:to:from:subject:cc :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=1umpD1Q0BARp14yG5etCeutnvUghZER7FsSDhDr7vNs=; b=zBHbSfP4RNaRqsbs4yddPOYssay93AN7tnrlYWTJfhZnMIkkFfr5+6knW91rLLzHqE btWNGH+1fl4Rfoqt0wc5ePzjng2tlUp0OkOAIJRcnzzzS6Wqr8Fw++wsTsuTc3OhJ43K l+GJSAiGbaKTrsOF8mTRWm8+qDpRKfSGERpUYkJAPVMuQ1bsW80ptNa5wgxV7eiWXn/G j3tz1K5UYgWGz9jR43uYa3BU96QWdVciviPdKQAncOn16GBCX3KlJGqb8R/t7/BBPuWo cxPEQfBeGLB9Upn/hwo0dGHgvtf3HcAguyPFr/IvEuNzwCsW+QQXIb5BBfdiPrAKqD6O rknw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=1On4akDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p22-20020a639516000000b005302f7ec8c4si16081729pgd.845.2023.05.15.02.47.46; Mon, 15 May 2023 02:47:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=1On4akDe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240247AbjEOJl3 (ORCPT + 99 others); Mon, 15 May 2023 05:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237978AbjEOJlF (ORCPT ); Mon, 15 May 2023 05:41:05 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5543A4C32 for ; Mon, 15 May 2023 02:38:05 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-96aa0cab88dso540918466b.1 for ; Mon, 15 May 2023 02:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1684143477; x=1686735477; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1umpD1Q0BARp14yG5etCeutnvUghZER7FsSDhDr7vNs=; b=1On4akDeNwD08zQZqtFvg1vfMgOFettnQ892Q3EGUqILoFdRkSaqa3lpRq0i2kXdwi cSAjoU1cUBTop8qhrc7sotDhywZv8/MDUnjPxYXwhQzadYvp60LrWmk1wr80sJuRrPhY DJ7AZr2mT+nsu6f9KH24Omc4bN/LJUczGqYQKvc2qM32BoZ3pjndGlaS3CyqWiJPLoI1 dpP1qp8GYCpTuby0dbmjfpzBPPh0VyfPwEzrhyBz2SxvgrV/geyK15jkfQpEWcr/vPtg IDVDRFTvuJx4ipYg3rih9C8jxzbZhNNP4n9iSTcyAnGVanBmfdj9jCajhuQRA6O5RbAm ufqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143477; x=1686735477; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1umpD1Q0BARp14yG5etCeutnvUghZER7FsSDhDr7vNs=; b=PRS+tXP2aIbLO5FIuVaLf334eMd0txkuUKMDizLBkEwGS4cNejtdAExLPbIs3fXRGx I2JJirVymlVQxIG436Nm4ikzpUwk/6YXfqFhjN0GDKB1UsSOtK3YcQviEroc6AtGjJre pDT5NSl9LswdmgdB4CQUw4jBZ6wPxS0EVawEOyNS9aXoIb7CiO4PtJ36KAp/0X8IftuD SYVKxw1wdp66D5mDfrFizRhRm8gineszlLbmGH50gW3S+ZvQGMQDIhZhAPOu2QPRtV34 +ReA6A7yESuCjxGLl1tGKLreG1c7r66nEcwzqjWSoSLuRQRxVA8x/1Fnm+oM2QEbCI1K prEg== X-Gm-Message-State: AC+VfDyx1hHZPzoT/5AYOqiHqLIHJQFNv3fU2s51d9NJXMK6fIWm5slj UngYi56Hi/smV24MCmId2s0buA== X-Received: by 2002:a17:907:97ce:b0:96a:4bca:8408 with SMTP id js14-20020a17090797ce00b0096a4bca8408mr16379768ejc.60.1684143476937; Mon, 15 May 2023 02:37:56 -0700 (PDT) Received: from localhost (k10064.upc-k.chello.nl. [62.108.10.64]) by smtp.gmail.com with ESMTPSA id la26-20020a170906ad9a00b00967a18df1easm9224120ejb.117.2023.05.15.02.37.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 May 2023 02:37:56 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 15 May 2023 11:37:55 +0200 Message-Id: Cc: , , , , "Abaci Robot" Subject: Re: [PATCH -next] fastrpc: Use memdup_user instead of kmalloc/copy_from_user From: "Luca Weiss" To: "Yang Li" , X-Mailer: aerc 0.15.1 References: <20230515092604.79990-1-yang.lee@linux.alibaba.com> In-Reply-To: <20230515092604.79990-1-yang.lee@linux.alibaba.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yang Li, On Mon May 15, 2023 at 11:26 AM CEST, Yang Li wrote: > Use memdup_user rather than duplicating its implementation, which > makes code simple and easy to understand, and silence the following > warning: > > ./drivers/misc/fastrpc.c:1259:8-15: WARNING opportunity for memdup_user > > Reported-by: Abaci Robot > Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3D4949 > Signed-off-by: Yang Li > --- > drivers/misc/fastrpc.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index f60bbf99485c..a897dab13c61 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -1256,16 +1256,9 @@ static int fastrpc_init_create_static_process(stru= ct fastrpc_user *fl, > goto err; > } > =20 > - name =3D kzalloc(init.namelen, GFP_KERNEL); > - if (!name) { > - err =3D -ENOMEM; > - goto err; > - } > - > - if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.name= len)) { > - err =3D -EFAULT; > - goto err_name; > - } > + name =3D memdup_user((void __user *)(uintptr_t)init.name, init.namelen)= ; > + if (IS_ERR(name)) > + return PTR_ERR(name); Don't we still need a "goto err;" here to free args? Something like this: if (IS_ERR(name)) { err =3D PTR_ERR(name); goto err; } Regards Luca > =20 > if (!fl->cctx->remote_heap) { > err =3D fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,