Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp291571pxk; Wed, 23 Sep 2020 03:24:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdS29jr7P0luY26aOXag+sHR2biIqEJ+35QDj5jf1quHNauowxcae6OpLz0qe+nHVpIdqg X-Received: by 2002:a17:906:7d5:: with SMTP id m21mr9364009ejc.538.1600856667403; Wed, 23 Sep 2020 03:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600856667; cv=none; d=google.com; s=arc-20160816; b=UqgKC2Ev9eJpjpCfG1RwCe53ZnoMxAJUMuxAvsewZDz0K7zYA3jlDjJHhgWlijC8/G VDWlGEpy3agPyNtSuXDVCWZijlRM/E4DPdaP2asHk+k5b7Yj4hrpxWLENVTDfUATnoyV DgE+dBf8VTgyr30QwurJxc9b0e5ZagdOdBZ5H+hvCHph+fb3obQ9BgV/QgJXPKbxd3AB c90Ak7wOaZyJtcJAluFR9ga+OaypEB7Cddi3GMAubOZjb0a3KTXAAVZF76solyTvW95m +EBbRkHxOcp/5M/Fw8/aURjuIbNwN5Kx/6vcGr+NXuwyXkhbxxwNod6eDXDMvVqORe8J wZ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=jbE3xqWmrav8NliPhuXnwoHoxrt72ZS1tqSJlMbrbqs=; b=pHPDtlnQKcUapqwXvmetaN8STZ7mPB9sUvuBaFC/WxyUAEi+FqcF8EOLM1S1RYGl1a G1cZXePtKT8Ah97cg/P8ThvuwfYsZdRitRxsD3UP+w8O7ehVDSROMeBVvSarlddbJINr fnM7VLB4e4KeoGsuihNUdt3CSLZfn9TRtwk/E+yxqPWeYH5BzWCcY5swFg1GLvxffJAs UtTaq2B2iX+J3DJjA5V6Fju67hJzn+PP6fJlgPk0L5ro+LWmSk7iE1a8ddlJXQDCUdHs xhFGuD9oXd0vtsuvel37RfyUGMvDhfoHcagpLg4gDgbvWdljYV0EQYtjCa6D7qYP/zxA 2ydw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rUuUIJ0j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si11473120ejt.659.2020.09.23.03.24.03; Wed, 23 Sep 2020 03:24:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rUuUIJ0j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726630AbgIWKW6 (ORCPT + 99 others); Wed, 23 Sep 2020 06:22:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:60038 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbgIWKW6 (ORCPT ); Wed, 23 Sep 2020 06:22:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600856577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jbE3xqWmrav8NliPhuXnwoHoxrt72ZS1tqSJlMbrbqs=; b=rUuUIJ0j6ln/3DCMxMrtfIeELX/iS75yliSp+iYcNLunbappoz/0BURyQiFr1m7mjZq7WL xDiiqnO3Kz9T5khtGzgVo7s9tFvcvmbLWu0IBTMncSxWcCxcAtMNSNwaIsax54twjDHMs2 nUgOTeGhu7fNiGKZdzBacZ6kxIggVyo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 504AFB009; Wed, 23 Sep 2020 10:23:34 +0000 (UTC) Message-ID: <1600856557.26851.6.camel@suse.com> Subject: Re: [PATCH 3/4] net: usb: rtl8150: use usb_control_msg_recv() and usb_control_msg_send() From: Oliver Neukum To: Himadri Pandya , davem@davemloft.net, kuba@kernel.org, pankaj.laxminarayan.bharadiya@intel.com, keescook@chromium.org, yuehaibing@huawei.com, petkan@nucleusys.com, ogiannou@gmail.com Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, gregkh@linuxfoundation.org Date: Wed, 23 Sep 2020 12:22:37 +0200 In-Reply-To: <20200923090519.361-4-himadrispandya@gmail.com> References: <20200923090519.361-1-himadrispandya@gmail.com> <20200923090519.361-4-himadrispandya@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Mittwoch, den 23.09.2020, 14:35 +0530 schrieb Himadri Pandya: Hi, > Many usage of usb_control_msg() do not have proper error check on return > value leaving scope for bugs on short reads. New usb_control_msg_recv() > and usb_control_msg_send() nicely wraps usb_control_msg() with proper > error check. Hence use the wrappers instead of calling usb_control_msg() > directly. > > Signed-off-by: Himadri Pandya Nacked-by: Oliver Neukum > --- > drivers/net/usb/rtl8150.c | 32 ++++++-------------------------- > 1 file changed, 6 insertions(+), 26 deletions(-) > > diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c > index 733f120c852b..e3002b675921 100644 > --- a/drivers/net/usb/rtl8150.c > +++ b/drivers/net/usb/rtl8150.c > @@ -152,36 +152,16 @@ static const char driver_name [] = "rtl8150"; > */ > static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) > { > - void *buf; > - int ret; > - > - buf = kmalloc(size, GFP_NOIO); GFP_NOIO is used here for a reason. You need to use this helper while in contexts of error recovery and runtime PM. > - if (!buf) > - return -ENOMEM; > - > - ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), > - RTL8150_REQ_GET_REGS, RTL8150_REQT_READ, > - indx, 0, buf, size, 500); > - if (ret > 0 && ret <= size) > - memcpy(data, buf, ret); > - kfree(buf); > - return ret; > + return usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS, > + RTL8150_REQT_READ, indx, 0, data, > + size, 500); This internally uses kmemdup() with GFP_KERNEL. You cannot make this change. The API does not support it. I am afraid we will have to change the API first, before more such changes are done. I would suggest dropping the whole series for now. Regards Oliver