Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp504122pxk; Wed, 23 Sep 2020 08:34:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5nUSTf07ylRrOFrCN6F1rlFXnsRf0MF9cBO49Fx6gKBF990/t+l12qghmqSc8tVOMG29k X-Received: by 2002:a05:6402:176c:: with SMTP id da12mr10552771edb.386.1600875276049; Wed, 23 Sep 2020 08:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600875276; cv=none; d=google.com; s=arc-20160816; b=k0OE3VDXUX3FJbAON9qw0h1g5jkIS1v8D3ZNegR5xy4iVcEpIqbqPNELNxIhnY4Wzc zqgZCrBktpeDcZFcsR42P9xQNRDF+vUHUOkbk+ClbRpP5LvHpaJEKhpBAzcpgxohLZOk SdewGdhni9c4bSuL1kvip+NM7xssqa1shw23fizxaAs2khKOZrPvON5OGy7lzWGgEPR5 3HHQk7I5Rsfee796tugBSLLQ68WJpgUuqC6HxGWXIUL7dghZ07rEoPd41rp+kVv5Re3D S3YhMQkmhsh+888rGHWifkgnA73VrOME6lxCNu8o719k1hivuVRRdeACl5bRYYjdKx06 9OKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4DYJKE8l8EdESOXVwsp+gos89esEsmURD8s5B4Bsfec=; b=L0IU1nFylNOnMp02jHHlQBoDkjjFfAqLUQIRY4Rrxbsfj/Ns4+ayPXDmH0tvH7fuaB xZ2wVuxF9lRrxp53/Bu+Rho1AAgxNrm/pYfsn15ulVnKTJaDLxIYdTnKj03Z6/OOgXlA nCwaCRUAv8qM1xXQ++Xk8YbX+7bPo4SdsIxo4pGmCFP92qTciUdZu4NReHAR1UcEpofi uPmlEtIfq1J3PueX60CvHg72AIRBEm6QWQHGMdm0FukQq8+Fwh9tkEpIY0C9cGRlWzUD 5iGoZ04AGXOz4XJKqka0NW7rq1dYG99+0UHnAUhMksdqGPEweLycO3ZBIBU6RbiAobG1 sLyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nucleusys.com header.s=x header.b=RSQ+DQS4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b36si106708edf.526.2020.09.23.08.34.09; Wed, 23 Sep 2020 08:34:36 -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=fail header.i=@nucleusys.com header.s=x header.b=RSQ+DQS4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbgIWPcq (ORCPT + 99 others); Wed, 23 Sep 2020 11:32:46 -0400 Received: from lan.nucleusys.com ([92.247.61.126]:60650 "EHLO zztop.nucleusys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726265AbgIWPcq (ORCPT ); Wed, 23 Sep 2020 11:32:46 -0400 X-Greylist: delayed 2630 seconds by postgrey-1.27 at vger.kernel.org; Wed, 23 Sep 2020 11:32:45 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nucleusys.com; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4DYJKE8l8EdESOXVwsp+gos89esEsmURD8s5B4Bsfec=; b=RSQ+DQS4PaLen4FanX1zUpusmC OHWXejqIFItnVTGDp+b/dg12zVaDRxod2M2lHqBTd1wuU9VdN4tAlPOYuXIbLyW6webaKVGsHb4sU +Zv3/lgtW70dj7YK6MLfjmP/UtcK+EgPmtQCn+YK7eXj64c571iIXke3Ne1v7OP9dCYU=; Received: from [94.26.108.4] (helo=karbon) by zztop.nucleusys.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kL64P-0005m4-T2; Wed, 23 Sep 2020 17:48:34 +0300 Date: Wed, 23 Sep 2020 17:48:32 +0300 From: Petko Manolov To: Oliver Neukum Cc: Himadri Pandya , davem@davemloft.net, kuba@kernel.org, pankaj.laxminarayan.bharadiya@intel.com, keescook@chromium.org, yuehaibing@huawei.com, ogiannou@gmail.com, linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, gregkh@linuxfoundation.org Subject: Re: [PATCH 3/4] net: usb: rtl8150: use usb_control_msg_recv() and usb_control_msg_send() Message-ID: <20200923144832.GA11151@karbon> References: <20200923090519.361-1-himadrispandya@gmail.com> <20200923090519.361-4-himadrispandya@gmail.com> <1600856557.26851.6.camel@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1600856557.26851.6.camel@suse.com> X-Spam-Score: -1.0 (-) X-Spam-Report: Spam detection software, running on the system "zztop.nucleusys.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 20-09-23 12:22:37, Oliver Neukum wrote: > 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 > > [...] Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-09-23 12:22:37, Oliver Neukum wrote: > 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. One possible fix is to add yet another argument to usb_control_msg_recv(), which would be the GFP_XYZ flag to pass on to kmemdup(). Up to Greg, of course. cheers, Petko