From patchwork Mon Mar 13 12:40:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9620629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AC70760414 for ; Mon, 13 Mar 2017 12:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AF832848B for ; Mon, 13 Mar 2017 12:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DFCC2848E; Mon, 13 Mar 2017 12:40:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F22A72848B for ; Mon, 13 Mar 2017 12:40:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751490AbdCMMkv (ORCPT ); Mon, 13 Mar 2017 08:40:51 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36247 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbdCMMku (ORCPT ); Mon, 13 Mar 2017 08:40:50 -0400 Received: by mail-lf0-f66.google.com with SMTP id g70so11703922lfh.3; Mon, 13 Mar 2017 05:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=sl0nkrwe3pjCok3FHDqgKTD6PFJiEgbeULk/+UPUXfY=; b=vRHw3SlBHYCTB8/obb43Ngnnee2rMZf4Ppqc+/kaR61A06IRDQGKsTZumo5H1MZhg+ XeETZEZOTgIJXfJ8/LsWakjFFhRGrwbyJQgoDIjRC057NPl6XbvwZEnTK8z7TH6dgZ9O R0Bo2aVxHjRAlHbRUM/n9XNsUOslU90ZwPLVbkKpQCeglyyuG4E3VAfq860diEy3pj94 W5LKkir5Ady12Mx1TCYWc5gYfGTmCu8p4gWrjH71E9B+CfcF74nQ2zZI3x5VHaZzmuj7 4+z2PISO4WAgdwh+gS4JICj7YsQ8LejSsI6yshqP/3lK3B4sQBFaAeQRdbMsG1ZOGUp9 0cEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=sl0nkrwe3pjCok3FHDqgKTD6PFJiEgbeULk/+UPUXfY=; b=fuGfnDPcCIeA/fDONAGfYr5ADIIKHHx16kQqZ1P3TcMYXeWtQ3BK2voG4i9qmO2y6t bz7Ot+LZ6Xkxw/CCglCZ3T0rMv9xOpeBoKbaMUQEyLci0XKWGFT+lGJ0OgVG8aohVXQ8 Aj4sj19Ym5cyoUzMmfxUHmKTvTYth5EihwHa3yFKoCDEJBqUO+zf75nIoYHJaK8z0Idy p81h9PCrRRY0ytKwdczd5ZpVfRMI6XS5f8n056GFwcK0KJH9FEpkrpNxj54/hk2IEuJd nCsitYlVMVgUj7eYPjbILWP5/hBX8xQuNtfEVZnGxfriRd56IC2sm3kmOyhP7BeF5CXZ ZILQ== X-Gm-Message-State: AMke39nMsWJIBU3nJCpmgfqW5jCfIbeFx4rhN5TluBLrAv4LQY5q/mCHaZAJEWjzrbeJXA== X-Received: by 10.25.207.81 with SMTP id f78mr8239092lfg.4.1489408847562; Mon, 13 Mar 2017 05:40:47 -0700 (PDT) Received: from xi.terra ([84.216.234.102]) by smtp.gmail.com with ESMTPSA id r204sm3614924lff.57.2017.03.13.05.40.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 05:40:46 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1cnPHC-0007On-Nv; Mon, 13 Mar 2017 13:40:38 +0100 From: Johan Hovold To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , David Vrabel Subject: [PATCH] mmc: ushc: fix NULL-deref at probe Date: Mon, 13 Mar 2017 13:40:22 +0100 Message-Id: <20170313124022.28401-1-johan@kernel.org> X-Mailer: git-send-email 2.12.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: stable # 2.6.37 Cc: David Vrabel Signed-off-by: Johan Hovold --- drivers/mmc/host/ushc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c index d2c386f09d69..1d843357422e 100644 --- a/drivers/mmc/host/ushc.c +++ b/drivers/mmc/host/ushc.c @@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id 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;