From patchwork Mon Dec 7 18:42:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 7789181 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DED169F349 for ; Mon, 7 Dec 2015 18:42:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 124F82054C for ; Mon, 7 Dec 2015 18:42:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FD9B2053C for ; Mon, 7 Dec 2015 18:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932285AbbLGSmV (ORCPT ); Mon, 7 Dec 2015 13:42:21 -0500 Received: from resqmta-po-06v.sys.comcast.net ([96.114.154.165]:43277 "EHLO resqmta-po-06v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932649AbbLGSmQ (ORCPT ); Mon, 7 Dec 2015 13:42:16 -0500 Received: from resomta-po-03v.sys.comcast.net ([96.114.154.227]) by resqmta-po-06v.sys.comcast.net with comcast id qihx1r00A4ueUHc01iiFSG; Mon, 07 Dec 2015 18:42:15 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-03v.sys.comcast.net with comcast id qiiD1r00V1LXgTt01iiDC7; Mon, 07 Dec 2015 18:42:15 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 883CD9F309; Mon, 7 Dec 2015 11:42:13 -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 v2 MC Next Gen] sound/usb: Fix out of bounds access in media_entity_init() Date: Mon, 7 Dec 2015 11:42:12 -0700 Message-Id: <1449513732-5482-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=1449513735; bh=8TOeH7RLS5db0mdoW5PPFHHnjhsKGoCPNqWlGGPLuns=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=ubzdicAyAPzj/zhyIh0t5yVIWvilAgBGly73DrwlFFKSnD7sthWKBqXb/CN6RlI0D vjjXAGrcn5nJC1DX6Or4dKf8+wH7dW8+8gK0RGHs3MDI7f5lGOJzSBjid94BVhY+Jh ilVN5GNZVKlZ0/jr7TGC5kMlMlk7z8osV+k3gtGecxtBygA/PqCtCYhHBKF570SNYE mK/WHZDV+JyYX0trsj0kyfx6Zn6MW920+ht/SBQS4PbZtGC/rW4AEA0+QPDW6BEF4A yT6uEFmB8gjdRaaFGvH/RzmQ0+Ci0GfdQkJtKTjjO3fcpYtfpZ8BAjQEZ9xYjyXTdG u6wuPUps40chw== 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=unavailable 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 --- Changes since v1: Change to address review comment from Takashi Iwai This patch fixes the mixer patch below: https://patchwork.linuxtv.org/patch/31827/ sound/usb/media.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/media.c b/sound/usb/media.c index bebe27b..b0d283f 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(*mctl), GFP_KERNEL); if (!mctl) return -ENOMEM;