Return-Path: Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Ulf Hansson" , "David Vrabel" , "Johan Hovold" Date: Sun, 16 Jul 2017 14:56:38 +0100 Message-ID: Subject: [PATCH 3.2 26/95] mmc: ushc: fix NULL-deref at probe In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: 3.2.91-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 181302dc7239add8ab1449c23ecab193f52ee6ab upstream. Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints. Fixes: 53f3a9e26ed5 ("mmc: USB SD Host Controller (USHC) driver") Cc: David Vrabel Signed-off-by: Johan Hovold Signed-off-by: Ulf Hansson Signed-off-by: Ben Hutchings --- drivers/mmc/host/ushc.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/mmc/host/ushc.c +++ b/drivers/mmc/host/ushc.c @@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interfa struct ushc_data *ushc; int ret; + if (intf->cur_altsetting->desc.bNumEndpoints < 1) + return -ENODEV; + mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev); if (mmc == NULL) return -ENOMEM;