Received: by 10.213.65.68 with SMTP id h4csp508765imn; Fri, 16 Mar 2018 09:54:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELuJLL9ydvVGFuz633IShPT5iUtmOqPgNYMryJ6Qa58t2VJ9OBue1RvsGtPKoZq9YumaRPkF X-Received: by 2002:a17:902:4083:: with SMTP id c3-v6mr2885392pld.70.1521219283657; Fri, 16 Mar 2018 09:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521219283; cv=none; d=google.com; s=arc-20160816; b=lteBXrcWNu9lE0EnmhIE1ofOjD5+pYyPN+d96aJL66bHhJ/zPt9F6YmDaeMfwZ86Pl YoQF5ukNIZgjg+7sFXz++yyYfR8yjfiRcuw5XKwjx65kwYp2YlQo0bodm4M5R0+8O6aE +EsBpjuQH5BMKC3WHKhDSoGODmiP7pOoMSILk3NHLiiO1AWmYqzCl297EfKK2qV/R2C3 NVa/Tothxdzpf+rb5skCBUfZtt/mz0QuzeN9LZ+p5FxBTr7l/JuFHRJYfzlEaACMfTsD DkQB6TjdKKFOZg2hzvKU8IhoSwFQCCspeV9whPDyFObrPtokFevSupNLuOSqCIA2z7XF T7ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EE21BYHr4lJ4IZgI1PmB3fYhMboj9BO4YzDsnQTWngE=; b=grkgUuNVypUHFLDHKF7DVwi60NtYOR0dA/FNuHrCtgH28TFpW9wPwxSTgcianXxgdC 48RNvp2PnoykUFFWAF4A2d/t9yS9kg19zmoUMj1KNu+d4QErW+meLDG//9U8i5JVjdxq 7nmebIjl0tCtn01b5nFM2MS+QL4ksfsmivVxbCyD8mazPEGaZ4yMVDc++owEREolRuEM bT2Jujxw566vMAUGjojpspYRolE3y2Dn6xeMFy4yagCFp6SE7M+R57tfHf1ZLW/32ydX 0x7OEmVGjJzVgDNzfuw5mj7VEXm76ekhGErHz903l1m5KX/VhEi/YfojVP20wxwccuu+ gWmA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si5193906pgv.144.2018.03.16.09.54.29; Fri, 16 Mar 2018 09:54:43 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbeCPQxg (ORCPT + 99 others); Fri, 16 Mar 2018 12:53:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39426 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933943AbeCPPe0 (ORCPT ); Fri, 16 Mar 2018 11:34:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 65A28F71; Fri, 16 Mar 2018 15:34:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Shuah Khan , Krzysztof Opasiak Subject: [PATCH 4.14 017/109] usbip: vudc: fix null pointer dereference on udc->lock Date: Fri, 16 Mar 2018 16:22:46 +0100 Message-Id: <20180316152330.899540834@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King commit df3334c223a033f562645712e832ca4cbb326bbf upstream. Currently the driver attempts to spin lock on udc->lock before a NULL pointer check is performed on udc, hence there is a potential null pointer dereference on udc->lock. Fix this by moving the null check on udc before the lock occurs. Fixes: ea6873a45a22 ("usbip: vudc: Add SysFS infrastructure for VUDC") Signed-off-by: Colin Ian King Acked-by: Shuah Khan Reviewed-by: Krzysztof Opasiak Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vudc_sysfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/usb/usbip/vudc_sysfs.c +++ b/drivers/usb/usbip/vudc_sysfs.c @@ -117,10 +117,14 @@ static ssize_t store_sockfd(struct devic if (rv != 0) return -EINVAL; + if (!udc) { + dev_err(dev, "no device"); + return -ENODEV; + } spin_lock_irqsave(&udc->lock, flags); /* Don't export what we don't have */ - if (!udc || !udc->driver || !udc->pullup) { - dev_err(dev, "no device or gadget not bound"); + if (!udc->driver || !udc->pullup) { + dev_err(dev, "gadget not bound"); ret = -ENODEV; goto unlock; }