Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6551682ybx; Mon, 11 Nov 2019 10:49:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxegwfqbVYemGjLeO/++CnYV5jLI7KF8ZPQh2I4u4NLmec3zZllbPtphco6GEcb5I7C1ffJ X-Received: by 2002:a17:906:240c:: with SMTP id z12mr24552624eja.35.1573498165085; Mon, 11 Nov 2019 10:49:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498165; cv=none; d=google.com; s=arc-20160816; b=wxVvc1iJj50735w2KLg25tj4kghtrEA8X8q9u8Zft8gd+ne1D0EcwAtUgpFcnILOWg EkW9CHgc4/TAp1A/s03gQ14QfWWpdGVyd55iePz6WH+hFtXa2rdtDGKkG2x7pJrNnjlv TGRtnnQSx55i5cCl4pHma7p2hl5bDt0YhMQI85s7uU1MIoAHpfqb1JcIY9X1hnxa6o26 1SvS8X4lsdU839PHNIMfXTO+QXKJxZyflID9t0AJr9zLx6xx7DTFKlq9E79m0oB1LXkd 0bzEB5oFSzS6K6/HBctN1qpDG4PceeB7arTktxtnKf91EECTrah5qIN36+DZhZT+WJhX j+mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m/1o4cikvfuUQeLPn+ufGT6b2SwSxEUGs6hkhuvO2+A=; b=yObivHwwa0NV/DEfb4Xpt07bxT+MR3Ayaer/Ag5W4I3HQ+NXOKt3eF1dL0zbudgGh6 fJrKtQNt5LtmJAO+9sXKisb2k+npTZwnGWXQAef35o4enr9vbCZfxhcbuJBbB4npSxmS i39d+n7B7xiCMsnp73z4wCtkp9b2p5a54ikW5Gk26myAyyCtPc/0KJWj7GO/bkyC/XaX GiN07jJAeP+gePtyIH37cy4eHbbzyHzSdksoKUHMt8KcY3Vzc1z2meQKpB7b+k5lGml+ xX5VVMckJyPzp5k4jBKdET3qSvWw52oEf7JACH6k1+ue5sEd8oav+OkpYNAbgwW3cDJn bwVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sXI8PJHv; 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 v9si12546784edl.90.2019.11.11.10.49.01; Mon, 11 Nov 2019 10:49:25 -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=@kernel.org header.s=default header.b=sXI8PJHv; 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 S1729881AbfKKSpf (ORCPT + 99 others); Mon, 11 Nov 2019 13:45:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:37740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729882AbfKKSpe (ORCPT ); Mon, 11 Nov 2019 13:45:34 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DDCB21655; Mon, 11 Nov 2019 18:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497933; bh=L1kLxcvshvOYxkYmrXxv0EM21Jlx7kQrRA384vulsYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sXI8PJHvRNC6rYEBlha3oDm7cc8NDJtCxc+pLRTECOF9PNZNkgRunEGewWok4AdsM KJTnI7kZ07FGGnPRxx5kLygnBYGXchDsfVEp4bIXNDbovZRWBSayhH8xld5BhPkoz/ /6Zf5wXE27Ctief3nPr8RaSqRHt4zCY0rBrLLHqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, GwanYeong Kim , Shuah Khan , Sasha Levin Subject: [PATCH 4.19 100/125] usbip: tools: Fix read_usb_vudc_device() error path handling Date: Mon, 11 Nov 2019 19:28:59 +0100 Message-Id: <20191111181453.260215108@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: GwanYeong Kim [ Upstream commit 28df0642abbf6d66908a2858922a7e4b21cdd8c2 ] This isn't really accurate right. fread() doesn't always return 0 in error. It could return < number of elements and set errno. Signed-off-by: GwanYeong Kim Acked-by: Shuah Khan Link: https://lore.kernel.org/r/20191018032223.4644-1-gy741.kim@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- tools/usb/usbip/libsrc/usbip_device_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c index ec3a0b794f159..67ae6c1557b8c 100644 --- a/tools/usb/usbip/libsrc/usbip_device_driver.c +++ b/tools/usb/usbip/libsrc/usbip_device_driver.c @@ -81,7 +81,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) FILE *fd = NULL; struct udev_device *plat; const char *speed; - int ret = 0; + size_t ret; plat = udev_device_get_parent(sdev); path = udev_device_get_syspath(plat); @@ -91,8 +91,10 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) if (!fd) return -1; ret = fread((char *) &descr, sizeof(descr), 1, fd); - if (ret < 0) + if (ret != 1) { + err("Cannot read vudc device descr file: %s", strerror(errno)); goto err; + } fclose(fd); copy_descr_attr(dev, &descr, bDeviceClass); -- 2.20.1