From patchwork Sat Dec 5 00:00:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 7773371 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3458EBEEE1 for ; Sat, 5 Dec 2015 00:00:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 33A4620639 for ; Sat, 5 Dec 2015 00:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 715C320623 for ; Sat, 5 Dec 2015 00:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752104AbbLEAAi (ORCPT ); Fri, 4 Dec 2015 19:00:38 -0500 Received: from resqmta-po-12v.sys.comcast.net ([96.114.154.171]:36117 "EHLO resqmta-po-12v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751489AbbLEAAi (ORCPT ); Fri, 4 Dec 2015 19:00:38 -0500 Received: from resomta-po-18v.sys.comcast.net ([96.114.154.242]) by resqmta-po-12v.sys.comcast.net with comcast id pc0G1r0035E3ZMc01c0c9F; Sat, 05 Dec 2015 00:00:36 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-18v.sys.comcast.net with comcast id pc0a1r00C1LXgTt01c0agJ; Sat, 05 Dec 2015 00:00:36 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id D105F9F2DF; Fri, 4 Dec 2015 17:00:33 -0700 (MST) From: Shuah Khan To: mchehab@osg.samsung.com, tiwai@suse.de, perex@perex.cz, chehabrafael@gmail.com, hans.verkuil@cisco.com, prabhakar.csengg@gmail.com, chris.j.arges@canonical.com Cc: Shuah Khan , linux-media@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH MC Next Gen] sound/usb: Fix out of bounds access in media_entity_init() Date: Fri, 4 Dec 2015 17:00:29 -0700 Message-Id: <1449273629-4991-1-git-send-email-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1449273636; bh=BPhbdAVfYlZ3yFBbMkpO2c4gWE2rvrbC4H/gNDvUhog=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=NkDy+RMsCVStHB9aNfe5QQdezyHlS2xCnU/2GEy8DTSicEYdM2+0LrlrbJggfoDgc jGFdI++DA7iy8YpHjACPfxSoni0ImBpJ2ChTvXFVeohIfzcMCk+i5uaBZvrEpU/Uj2 53CTB2hoepqt4vT1HopReOek8WNByfqHlcNkmtHZ5SY8QT8iIzsbUpYM7zVA/JJv5H OgY9/SRH9riQGxwK9YtZbwdQVv61EeR7hRLAy/rJtsO5bqngB0CSDn7ggISXm64sdo Lfb7y0pkQOFlKBg7pbXG6lmJl1Ilb1nCsrqUaIuG0RdZA9bxUz2i6UOjsArV/iCr8q ndZaQd19q0d6w== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix the out of bounds access in media_entity_init() found by KASan. This is a result of media_mixer_init() failing to allocate memory for all 3 of its pads before calling media_entity_init(). Fix it to allocate memory for the right struct media_mixer_ctl instead of struct media_ctl. Signed-off-by: Shuah Khan --- This patch fixes the mixer patch below: https://patchwork.linuxtv.org/patch/31827/ sound/usb/media.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/usb/media.c b/sound/usb/media.c index bebe27b..0cb44b9 100644 --- a/sound/usb/media.c +++ b/sound/usb/media.c @@ -233,8 +233,8 @@ int media_mixer_init(struct snd_usb_audio *chip) if (mixer->media_mixer_ctl) continue; - /* allocate media_ctl */ - mctl = kzalloc(sizeof(struct media_ctl), GFP_KERNEL); + /* allocate media_mixer_ctl */ + mctl = kzalloc(sizeof(struct media_mixer_ctl), GFP_KERNEL); if (!mctl) return -ENOMEM; @@ -244,6 +244,7 @@ int media_mixer_init(struct snd_usb_audio *chip) mctl->media_pad[0].flags = MEDIA_PAD_FL_SINK; mctl->media_pad[1].flags = MEDIA_PAD_FL_SOURCE; mctl->media_pad[2].flags = MEDIA_PAD_FL_SOURCE; + media_entity_init(&mctl->media_entity, MEDIA_MIXER_PAD_MAX, mctl->media_pad); ret = media_device_register_entity(mctl->media_dev,