Received: by 10.223.185.116 with SMTP id b49csp4947383wrg; Tue, 27 Feb 2018 05:27:01 -0800 (PST) X-Google-Smtp-Source: AH8x225329aMuKcMH3HVxgIb3hbTMy2vAtTVbiZlkJpFgs/kuuEa9wPngcaliRLSIUWzrmrRp08C X-Received: by 2002:a17:902:57c1:: with SMTP id g1-v6mr14345554plj.381.1519738021820; Tue, 27 Feb 2018 05:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519738021; cv=none; d=google.com; s=arc-20160816; b=t1+axuxiZDf3oloy6Vn/+ECFlUV6UY9+US1zlBGbAJ7rLzCphg60+pDW/alGStNv8x HltQ9GTgPC7OXqweOrH9SSDCfpOUnDpdj3RHVnzIgyjxRpyssArDcVReoUTrrDL0jukC 1c9TcdKIh09OIVJ3CTfgC5H4iYfhhFer4XCKegLNPpRLwhfhLOdWol/Cs/GR16uBvzY/ agzNU7uZmtqtb9VyaAzRbg2qReHiXKWOsk32R5cBDTZAgp9H8Nc18KFmVXEkWz7Qg2dk lsoMTdCYXUU8zCDH8aWmYrs7rNUL2oF/HipdrCG5BZ/fpkNt5W99+CzRSLlPerbWsw+P Vz/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:cc:to:subject:dkim-signature :dkim-filter:arc-authentication-results; bh=j8lLkVc0UU6ussw+O5qxJa14Dwr75pMKZ/pvvIaNAl4=; b=Z9yohixxDo4bqH1qnIZNOgSbZO5e69//3X5aQj/9VtdyijLN8Qprrag7Yw8EC8DIww FOAqxRlTczSMdilXgLm05o/m/dYgQ/uHgtLP94YvcLCG7JSVf+aGCY3UDEujTrh/BS2g d77+9DhzT5ATR9vqR51fvzgwCKjbd8EAucmMcLRKQnr4vGptceOgqwVqgk3iKnsIYAUv NbmSSbz4EWj/2px0nH0dW7NV1+PZf+tQaZwwvuC49nuTFpxSekIDYdYhTTF5Nvdzm04f MhLYdldKoezrBqWfH3ht2sODF/Uv1g7wglZm+a7TfhVFDyRlvlkQxBtHc0qOB5BEsfH0 eiPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kIeugxwR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f32-v6si8507544plf.754.2018.02.27.05.26.45; Tue, 27 Feb 2018 05:27:01 -0800 (PST) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kIeugxwR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753264AbeB0NYz (ORCPT + 99 others); Tue, 27 Feb 2018 08:24:55 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:10114 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753081AbeB0NYx (ORCPT ); Tue, 27 Feb 2018 08:24:53 -0500 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180227132450epoutp036681ab0f53ba4bbc99f5610902093baf~XMY9UqKz90151101511epoutp03x; Tue, 27 Feb 2018 13:24:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180227132450epoutp036681ab0f53ba4bbc99f5610902093baf~XMY9UqKz90151101511epoutp03x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519737890; bh=j8lLkVc0UU6ussw+O5qxJa14Dwr75pMKZ/pvvIaNAl4=; h=Subject:To:Cc:From:Date:In-reply-to:References:From; b=kIeugxwRoEpulzvIpCSdyXNOp+bISjmWv1ZveFug2tFUXz6WrMb3SOiKwjZtlhsgM +lnUNpCTy0b3lOItdouJfqGnj68IUvu9V20EcoJuLLAc4xWdkKU71pZe0S77OYOv8B BTguz/ws+ZUZcoygye0xpirSFDkKIqAXFjbFCRjs= Received: from epsmges2p1.samsung.com (unknown [182.195.42.69]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20180227132449epcas2p2fa030a3f71aceb9c668a7f73e70e230e~XMY8TJoci2237222372epcas2p2G; Tue, 27 Feb 2018 13:24:49 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id EB.9E.04131.12C559A5; Tue, 27 Feb 2018 22:24:49 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180227132449epcas2p1a6d5d8261d23cd5509ec6b0f2bcfdc82~XMY7l0CAn0534905349epcas2p1U; Tue, 27 Feb 2018 13:24:49 +0000 (GMT) X-AuditID: b6c32a45-403ff70000001023-ed-5a955c2102ca Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E4.43.03890.02C559A5; Tue, 27 Feb 2018 22:24:48 +0900 (KST) Received: from [106.116.151.61] by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4T000M0999HS60@mmp1.samsung.com>; Tue, 27 Feb 2018 22:24:48 +0900 (KST) Subject: Re: [PATCH] usbip: vudc: fix null pointer dereference on udc->lock To: shuah@kernel.org, Colin King , Greg Kroah-Hartman , linux-usb@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan From: Krzysztof Opasiak Message-id: Date: Tue, 27 Feb 2018 14:24:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-version: 1.0 In-reply-to: <0e3059a0-1310-5d08-4623-f1cf34c52fc0@kernel.org> Content-type: text/plain; charset="utf-8"; format="flowed" Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMKsWRmVeSWpSXmKPExsWy7bCmha5izNQogwev9Sx+r+5ls2hevJ7N YustaYvLu+awWSxa1spsMeXlOnaLqV8+sDiwe8xq6GXz2LSqk81j/9w17B5b+u+ye3zeJBfA GsVlk5Kak1mWWqRvl8CVMfPKX8aCN7wV8zt6WBoYJ3J3MXJySAiYSJzuWsDUxcjFISSwg1Hi 99kPzBDOd0aJ20v/scNUTVxxnAXEFhLYzSjRNT8Uoug+o8Sf+cfZQBLCAt4SxyctYgFJiAh0 Mko0XZoBlmAWyJT43T2PtYuRg4NNQF9i3i5RkDCvgJ1Ef9cXJhCbRUBVYsLbL2DlogIREgun PmWEqBGU+DH5HthiTqD6FVfnMEKMtJJ49q+VFcIWl2huvckCYctLbF7zlhni6BNsEkfuJkHY LhIz5s9hhbCFJV4d3wL1mLTEs1UbGUFulhBYxygx+cJ+VggH6Mt9fY+gJllL/Fk1EeoZPomO w3/ZQZ6REOCV6GgTgijxkLjdsR5qgaPEyouNrJAQOsoocfpUA9sERrlZSB6aheSJWUiemIXk iQWMLKsYxVILinPTU4uNCgz1ihNzi0vz0vWS83M3MYKTipbrDsYZ53wOMQpwMCrx8B50nBIl xJpYVlyZe4hRgoNZSYR35eLJUUK8KYmVValF+fFFpTmpxYcYpTlYlMR52wJcooQE0hNLUrNT UwtSi2CyTBycUg2M6pl7W65lzHRWMTE/uqJxi7fZfz/R+meuE/ZGqkpusbvNM+WGTQXzuXrx x8cFA7h35R57nvVFYY3wxbbp5T/+8Bspq0vO66o88uy9hRJnMGfz15NBiawrnrx2W158IFFM Y426Tqn+hdui3XlqzjL7DB7tEN0Q9OHGPxe/8pulV+LKtPsPnV+vxFKckWioxVxUnAgAIMpx aiYDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsVy+t9jAV2FmKlRBlPXWVv8Xt3LZtG8eD2b xdZb0haXd81hs1i0rJXZYsrLdewWU798YHFg95jV0MvmsWlVJ5vH/rlr2D229N9l9/i8SS6A NYrLJiU1J7MstUjfLoErY+aVv4wFb3gr5nf0sDQwTuTuYuTkkBAwkZi44jhLFyMXh5DATkaJ 7sUXoZyHjBJXL85mAqkSFvCWOD5pEVhCRKCTUeLUxIlsIAlmgUyJbZdbGCE6jjJKfN/Wyt7F yMHBJqAvMW+XKEgNr4CdRH/XF7BBLAKqEhPefgHrFRWIkOhcOZ8FokZQ4sfke2A2J1D9iqtz GCHmm0l8eXmYFcIWl2huvckCYctLbF7zlnkCo8AsJO2zkLTMQtIyC0nLAkaWVYySqQXFuem5 xUYFRnmp5XrFibnFpXnpesn5uZsYgXGw7bBW/w7Gx0viDzEKcDAq8fDOkJsSJcSaWFZcmXuI UYKDWUmEd+XiyVFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEefnzj0UKCaQnlqRmp6YWpBbBZJk4 OKUaGJlf35jnsSr4tzvzl4+ZPU46He16//53WJa79DbJPdsmdyShNFRsclLls3dZG+fx7n3I ee9nOV+X/X5pPQa1TRY1ifV8upsmHftiGDBZy8rsS5PVmfy8Dh3xvQf3rdusUlBdt0ju6sbj ZjHLkpdps2wvLjr8adXEqV7F9wuTij58W6pyYfXzNCWW4oxEQy3mouJEAF20h4l/AgAA X-CMS-MailID: 20180227132449epcas2p1a6d5d8261d23cd5509ec6b0f2bcfdc82 X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180226164058epcas2p2bb0094cc06b3161a0d0b2a9cc6ce282f X-RootMTR: 20180226164058epcas2p2bb0094cc06b3161a0d0b2a9cc6ce282f References: <20180222173917.10841-1-colin.king@canonical.com> <0e3059a0-1310-5d08-4623-f1cf34c52fc0@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/26/2018 05:40 PM, Shuah Khan wrote: > On 02/22/2018 10:39 AM, Colin King wrote: >> From: Colin Ian King >> >> 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 >> --- >> drivers/usb/usbip/vudc_sysfs.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c >> index d86f72bbbb91..6dcd3ff655c3 100644 >> --- a/drivers/usb/usbip/vudc_sysfs.c >> +++ b/drivers/usb/usbip/vudc_sysfs.c >> @@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a >> 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; >> } >> > > Thanks for the patch. Looks good to me. > > Acked-by: Shuah Khan Reviewed-by: Krzysztof Opasiak but you could fix also a similar bug one one function above (dev_desc_read()) ;) Best regards, -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics