Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5038134ybh; Tue, 6 Aug 2019 23:16:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH/iHeYYkEKrvL2SOWLyaQ+TkoYFqdCmcekO3cl4Ux7eOsP9wKlo4Nark0ijPMJNvceaIh X-Received: by 2002:a17:90a:3ae8:: with SMTP id b95mr6670612pjc.68.1565158613060; Tue, 06 Aug 2019 23:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565158613; cv=none; d=google.com; s=arc-20160816; b=01Cm4HDWy4VEO1lyJwxdQaXPhZrclcu/FcxaDRhOw72YkNLUfIKVNiAXtfuYKNAxx0 MOnJRZVeIp+fQr6JenYEkKkb/qCY20HX3iWpC2U0gIbSYDLzky1CVb2Os2OhwoL0bNA+ GoLYVtd1uQgHE8Mv7oFhxD/WyKZhJ4jv8b9gwXSb7cSoPDHB+KFFApcqox+BXCctlUaC KYECemBNjQfiNjTWt2kfNyNTow5dFkrMnUvIndCBG6I1car4nPYLCszQZnLkiHX+V/+0 rV87FLrLlwPi6ktaTN9Z1B5zQQ0/j9p+m4/UUAeEX9eN0xQKlez5/zz7mH2/iKcz41+u UGzA== 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=cKMztz5qrVz81yDMYgUWhOlLfJVTidGNELtoP4Z/m7g=; b=AmE36un1YN7WtObDRaubmVWXnjgK8clgfksxZ5m0DV9B/CBdmrRZAky1s43EVDJlAh 741EV5Pk0OK5ZFl7k3iRvnDUR9dDI/1jC9O1nCIaIHeqJUCnY/NjdxzXgfWav5+TF5jU O0TDltNzj6UPA7wiHVulN8GGyepMknp3uNQfNjTFByq9dbtNj8zXSJpG+9kK+geuKQQu kd4EKZugp1fPeGkDwMrjH107e4zVFEqnA20hC0h7ZBdIhmnOUZcvNW1Dn7Bxug5MfMJi HmR0jXyzxHOftkFXstn26HaJMQYl5x80RokIk1ni4Cuh1F44ueqA9lkCZheQ4wTXKlQn OcMA== 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 t14si44706268ply.347.2019.08.06.23.16.37; Tue, 06 Aug 2019 23:16:53 -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 S1726883AbfHGGP4 (ORCPT + 99 others); Wed, 7 Aug 2019 02:15:56 -0400 Received: from ajax.cs.uga.edu ([128.192.4.6]:44652 "EHLO ajax.cs.uga.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbfHGGP4 (ORCPT ); Wed, 7 Aug 2019 02:15:56 -0400 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x776Fsfj059912 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 7 Aug 2019 02:15:55 -0400 Received: by mail-lf1-f41.google.com with SMTP id z15so58847743lfh.13 for ; Tue, 06 Aug 2019 23:15:55 -0700 (PDT) X-Gm-Message-State: APjAAAVccdD1E4zktA0/aEMQD7KPGRuYzPONAD6P9t8zWgp9LDh2BJEe YMkRuZvFqmQdC5D47APhjcdsVOcd0iwS+OrqYCQ= X-Received: by 2002:ac2:418f:: with SMTP id z15mr4688367lfh.177.1565158553796; Tue, 06 Aug 2019 23:15:53 -0700 (PDT) MIME-Version: 1.0 From: Wenwen Wang Date: Wed, 7 Aug 2019 02:15:17 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: [PATCH] ALSA: pcm: fix a memory leak bug To: Wenwen Wang Cc: Jaroslav Kysela , Takashi Iwai , Allison Randal , Thomas Gleixner , Greg Kroah-Hartman , "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 hiface_pcm_init(), 'rt' is firstly allocated through kzalloc(). Later on, hiface_pcm_init_urb() is invoked to initialize 'rt->out_urbs[i]'. However, if the initialization fails, 'rt' is not deallocated, leading to a memory leak bug. To fix the above issue, free 'rt' before returning the error. Signed-off-by: Wenwen Wang --- sound/usb/hiface/pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index 14fc1e1..5dbcd0d 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -599,8 +599,10 @@ int hiface_pcm_init(struct hiface_chip *chip, u8 extra_freq) for (i = 0; i < PCM_N_URBS; i++) { ret = hiface_pcm_init_urb(&rt->out_urbs[i], chip, OUT_EP, hiface_pcm_out_urb_handler); - if (ret < 0) + if (ret < 0) { + kfree(rt); return ret; + } } ret = snd_pcm_new(chip->card, "USB-SPDIF Audio", 0, 1, 0, &pcm); -- 2.7.4