Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp492784ybi; Fri, 7 Jun 2019 11:24:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyHAe+mRbxfcUpDj/9FuI3/nmvrjWa/R4nxFHBnglWQRKrmnPbkvSJUVjGVGvMtip9YfEF X-Received: by 2002:a17:90a:a785:: with SMTP id f5mr7280985pjq.4.1559931848199; Fri, 07 Jun 2019 11:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559931848; cv=none; d=google.com; s=arc-20160816; b=MPtvMiRH0Kne7hTR1M6rUmDX3ebc0OrvYgxKsRZuJ45SxOcKr4tKORwju0ROGTCZT2 tyZIwUJZWWZI7O28/e3O8x20LyqRZGnJhV3Jefsyk4KuV+/gI32dwm0GL05iz3tM8WYi nf5t1gq7RXiL4wzdilEuoUO0HxFk63CvnQGzwcJXUFfSLWv+wA1Tb2XpV+i1+tkwEQB0 dieG18XmzikgS2O77UhpoTm4U0le96BaroKa278BnqBryWmx7mOk8VC2ZmYcSOWbvxPf niplPegu6+1/QbTIfU+HZc5hrFN2OW8jLaVYsRL02UzyttweeAnpTm7VOdb2ewPkH0Oh mcyg== 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=m8DwUqJdrvAaKK+5pv0EDG3LAMZVUx7usdMhbNFZEjc=; b=E1YrAjSvEcypdJVUvZaqRF21HkOeosT55oSOy4r6IzKUVzU6Qm86OhNvJxm5BPMDwO 7uhr03dj9VgYIkzJf9zO/vpbnRRSoBzuz9ASniB0qY9ehqV7anDtXN0CFI8k/2/pC3/F G0a3LvZo5lEpGRC2lixyPugCrMiZQ9gSOqmSTiw0XGxchgWTPvPiOu62V3/rt5iHp6AC hZqKKrc6nWqbHS6LicMpiHTRJFpWB4KqrcmXsFQgt5p3yYi+KoyW9QglqkC8y3bp00Ed MVok8vp7Kd8aAnRd2/ZVxMKecCavxPmFh8XsgcW8HMr3EzWRg/YkKp/kJYN2iOqCtUHN L+RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EOsij1wP; 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 d19si2954894pfr.70.2019.06.07.11.23.52; Fri, 07 Jun 2019 11:24:08 -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; dkim=pass header.i=@kernel.org header.s=default header.b=EOsij1wP; 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 S1731603AbfFGPr2 (ORCPT + 99 others); Fri, 7 Jun 2019 11:47:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:60278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731106AbfFGPrZ (ORCPT ); Fri, 7 Jun 2019 11:47:25 -0400 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 1D47920657; Fri, 7 Jun 2019 15:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559922444; bh=v2VBqGjF1s75sFMv5h3TrDbJNPdzuphQwPyVU1cEs/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EOsij1wPz5ffjewrVd8P00qScWEbMEEBllbumpSvdvyOhg96KLVnJmQSJgSZ/uZY5 bpx5bh33h+wt1nQjMWCHta6ZazlOc29Sbzz8k/iUssm3ulUF9NKwlUTUxkab6grDy4 Pv/qDPILWyimuQWpIQkGZ69Zi5SHlt62HG+UM7IQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauro Carvalho Chehab Subject: [PATCH 5.1 16/85] media: smsusb: better handle optional alignment Date: Fri, 7 Jun 2019 17:39:01 +0200 Message-Id: <20190607153851.166516057@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607153849.101321647@linuxfoundation.org> References: <20190607153849.101321647@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: Mauro Carvalho Chehab commit a47686636d84eaec5c9c6e84bd5f96bed34d526d upstream. Most Siano devices require an alignment for the response. Changeset f3be52b0056a ("media: usb: siano: Fix general protection fault in smsusb") changed the logic with gets such aligment, but it now produces a sparce warning: drivers/media/usb/siano/smsusb.c: In function 'smsusb_init_device': drivers/media/usb/siano/smsusb.c:447:37: warning: 'in_maxp' may be used uninitialized in this function [-Wmaybe-uninitialized] 447 | dev->response_alignment = in_maxp - sizeof(struct sms_msg_hdr); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ The sparse message itself is bogus, but a broken (or fake) USB eeprom could produce a negative value for response_alignment. So, change the code in order to check if the result is not negative. Fixes: 31e0456de5be ("media: usb: siano: Fix general protection fault in smsusb") CC: Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/siano/smsusb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -400,7 +400,7 @@ static int smsusb_init_device(struct usb struct smsusb_device_t *dev; void *mdev; int i, rc; - int in_maxp = 0; + int align = 0; /* create device object */ dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL); @@ -418,14 +418,14 @@ static int smsusb_init_device(struct usb if (desc->bEndpointAddress & USB_DIR_IN) { dev->in_ep = desc->bEndpointAddress; - in_maxp = usb_endpoint_maxp(desc); + align = usb_endpoint_maxp(desc) - sizeof(struct sms_msg_hdr); } else { dev->out_ep = desc->bEndpointAddress; } } pr_debug("in_ep = %02x, out_ep = %02x\n", dev->in_ep, dev->out_ep); - if (!dev->in_ep || !dev->out_ep) { /* Missing endpoints? */ + if (!dev->in_ep || !dev->out_ep || align < 0) { /* Missing endpoints? */ smsusb_term_device(intf); return -ENODEV; } @@ -444,7 +444,7 @@ static int smsusb_init_device(struct usb /* fall-thru */ default: dev->buffer_size = USB2_BUFFER_SIZE; - dev->response_alignment = in_maxp - sizeof(struct sms_msg_hdr); + dev->response_alignment = align; params.flags |= SMS_DEVICE_FAMILY2; break;