Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3712450ybh; Tue, 6 Aug 2019 00:01:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoad+1Syu3wSm7PQXc2XPUcrvD6z2QjNg5FJ3bEbPVlszaenbrn91X/+rlslCd3k1abdg2 X-Received: by 2002:a17:90a:d998:: with SMTP id d24mr1621994pjv.89.1565074916187; Tue, 06 Aug 2019 00:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565074916; cv=none; d=google.com; s=arc-20160816; b=WByuxZwC+RdIoX82sNLNpMm195P/X2kI5MnSm4ykvAaZmoD9OdAtcODqC6PjYbPG38 JxIhmBpbmr6EOMj1PxsmYAXp01axejgfQN90DoO6U7Rii6jQ+QCdBWpjQ1h3ni4I3LBb D2XVc5Ee0Ba4hEoMoEoZt9T+PK9Vf4oGp+Tb1jnxiVIBPQCkOcHdvCsdo+54i1C8VcO9 BvwnNYajIHor74wHW4Rt8wniO+5FPEgqv4427jKN9A78QZ52SBBiLMdOOvqPWgCiS/Ev dCY4WyzDXa+Onx5UvNIJk0GO+0iV8/2dDLnAJMR7/+3AjaKYtf+R1F7x1uPGTP6dgy7Z AIcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version; bh=vDs0xWYCom2pwJzlr4o4rr5PoAc8EawCnsfifUwAdcI=; b=TiqUAvX/zum/Eb3Y99kPJ0pY2Xy191XJH7IrmZTLIprBXj3bxdgdWLXYqHiOJSUpl3 v1daSCu0JazmfaGTDlaFfxYnWkJeuGmO8uAT/vB0SMdFy6Q6aiKtbRSMHMY+SjmAmNQW AapxFFP3jhiKKWeBBPez8kdcmEADrHwySbiQr1fK1LmJ7iTXp6G5wBfxaBOYUb0E3Bpy tZNb/YJJP9lXO9THHCqGaxPyBzMmLWxBRJF4g36ZftYM+yLB3m+6i+XBYWeH/pqgHemL n8+NnzYKLQH1GWuNwX5qONYPjd5IgtLYwEhtysPz/wwVW0gGscJWA1PS7b9l7FHYHNsT /i8g== ARC-Authentication-Results: i=1; mx.google.com; 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 6si17928043pgb.201.2019.08.06.00.01.40; Tue, 06 Aug 2019 00:01:56 -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; 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 S1731948AbfHFHBF (ORCPT + 99 others); Tue, 6 Aug 2019 03:01:05 -0400 Received: from ajax.cs.uga.edu ([128.192.4.6]:59564 "EHLO ajax.cs.uga.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731557AbfHFHBF (ORCPT ); Tue, 6 Aug 2019 03:01:05 -0400 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x76713N6032292 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 6 Aug 2019 03:01:04 -0400 Received: by mail-lf1-f48.google.com with SMTP id h28so60088615lfj.5 for ; Tue, 06 Aug 2019 00:01:04 -0700 (PDT) X-Gm-Message-State: APjAAAXJZn0jGz2YEYN5eYho59GgwRavRcFVp0GUnLadpliTYXpfeFIn dJ2PXqF2IY+7jHF/9LHVyFRh2sI5rU2bnsXeNhc= X-Received: by 2002:a19:cbc4:: with SMTP id b187mr1253490lfg.27.1565074863147; Tue, 06 Aug 2019 00:01:03 -0700 (PDT) MIME-Version: 1.0 From: Wenwen Wang Date: Tue, 6 Aug 2019 03:00:27 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: [PATCH] ALSA: usb-audio: fix a memory leak bug To: Wenwen Wang Cc: Jaroslav Kysela , Takashi Iwai , Shuah Khan , Richard Fontana , Hans Verkuil , Thomas Gleixner , "moderated list:SOUND" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In snd_usb_get_audioformat_uac3(), a structure for channel maps 'chmap' is allocated through kzalloc() before the execution goto 'found_clock'. However, this structure is not deallocated if the memory allocation for 'pd' fails, leading to a memory leak bug. To fix the above issue, free 'fp->chmap' before returning NULL. Signed-off-by: Wenwen Wang --- sound/usb/stream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 7ee9d17..e852c7f 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -1043,6 +1043,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip, pd = kzalloc(sizeof(*pd), GFP_KERNEL); if (!pd) { + kfree(fp->chmap); kfree(fp->rate_table); kfree(fp); return NULL; -- 2.7.4