From patchwork Fri Jan 18 21:29:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 10771587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1373B139A for ; Fri, 18 Jan 2019 21:29:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0137230275 for ; Fri, 18 Jan 2019 21:29:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9AC6302E3; Fri, 18 Jan 2019 21:29:40 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A037A30275 for ; Fri, 18 Jan 2019 21:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729691AbfARV3f (ORCPT ); Fri, 18 Jan 2019 16:29:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:57724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729598AbfARV3e (ORCPT ); Fri, 18 Jan 2019 16:29:34 -0500 Received: from shuah-t480s.internal (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18CBB20896; Fri, 18 Jan 2019 21:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547846974; bh=4Wy9HHw4yohxCo423IljYqpK8zEHV671qXpcn7IEDfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wIm3cf/PLSfO999wvGqEUmAG1U72VcqdyUk+c5L0BrDytWqMQAWCNvd6m+XdykoD0 JtHlPxW5zv9Cjhce6+peLJTzsszDIj6gq8V22ze8bm5jd5u6iHKRvtfNQvoBeV5AuE 48v6tnDRQkpaQ/xpkztVqDKhpjfshCabDZoacG3A= From: Shuah Khan To: valentina.manea.m@gmail.com, shuah@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usbip: Fix vhci_urb_enqueue() URB null transfer buffer error path Date: Fri, 18 Jan 2019 14:29:31 -0700 Message-Id: <20190118212931.18482-2-skhan@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190118212931.18482-1-skhan@linuxfoundation.org> References: <20190118212931.18482-1-skhan@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shuah Khan Fix vhci_urb_enqueue() to print error and return error instead of failing with WARN_ON. Signed-off-by: Shuah Khan --- drivers/usb/usbip/vhci_hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 1e592ec94ba4..849ebfde87b5 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -702,8 +702,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag } vdev = &vhci_hcd->vdev[portnum-1]; - /* patch to usb_sg_init() is in 2.5.60 */ - BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length); + if (!urb->transfer_buffer && urb->transfer_buffer_length) { + dev_err(dev, "Null URB transfer buffer\n"); + return -EINVAL; + } spin_lock_irqsave(&vhci->lock, flags);