Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp784564ybt; Fri, 19 Jun 2020 13:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8tfN8zuqYZeLoLmB3ckY1uCqsMD2T8AzXEVNxAtH6ChGvDiAoewehmz6IWB3onySaTnsM X-Received: by 2002:a17:906:f155:: with SMTP id gw21mr5285224ejb.388.1592599452827; Fri, 19 Jun 2020 13:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592599452; cv=none; d=google.com; s=arc-20160816; b=nsVd0hmfky80lrE0bXBoNza490WiVuBjqSxBh7gLk4zz/W8QxWLArl2tUhZiGB3nHE i2cR60c9l/LAT/xK4BgkBz8QSNAT3VMFt33V8h63RrA+qtNiG49NDAfK3al6lUt1Wzty 6iT4DL5fnpwjeSIuGYdc/5vFp5q7xTO2k2NAHC6BMe0lwlZ+BWGH8/tBFg47koZZn7XC ctSysE03LLUI82q1NtPEExAJLpO7kx8UtaSu7LjZlg+I9oExDp1NMLGI4k9LK5lzzq2x onYJeR2tecxtuuG2NAPCH+bAhmAg+ks+DMpGWwZurJamLVYqWYlmGYDoz39Gi+fQj+CJ isKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z/DO+ioY6hH1EpsUA4UjDipHednpxcWrAw+IlWUl6co=; b=UYOaPnPVNn6deBHUjYBvOdx5cjk91hjvfnHzvRy0vsLzzPJDdiuSIu3Adqm+9Ni+Q8 TCrQCcaJ/dLVQPqzOu5AHkaAKMfoiKxZH/lFgHeEx/RUTDPmYr8V6C96kmsul7+AUCqI 1ndszyzPM7aoA2RsUnAx1pPQfAMgOWGuVCVF4nrtZYMyXTbfk4ZGDEbn+LViHXYlIFnS LSBItUHpsBiapvXLl5nRP/N/pcEkU6hX24O7vuyprGV4xC+fhyxR9hfmYbsSzcuECnXt ++nIVh9WkdV9iWeapDUO3BBDgrgl2er0lV42WzBNT3qvgMn6ZHyDnKoxGd/Hup33Vflw u+cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vugKJQL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b93si4760625edf.199.2020.06.19.13.43.50; Fri, 19 Jun 2020 13:44:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vugKJQL3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391013AbgFSPDb (ORCPT + 99 others); Fri, 19 Jun 2020 11:03:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:59986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390962AbgFSPDN (ORCPT ); Fri, 19 Jun 2020 11:03:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB76C21974; Fri, 19 Jun 2020 15:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578991; bh=rtbIHQjDReviVKNyg33EFXRysUUCSl3GNJoN1aNxlRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vugKJQL3ub59VZ6SbnTbArbobvlPZ7cAJGF7DUdfambwurSXXwJ+GP5Q6gOCkZIu+ 1mNEb17eGlS10q7GKj7vyCEoZmLNhbwV2uLwm/aB7R5At+npDTfZcBzkkC/CpvSjnB KROvlv4jZMU56IHzWKpisb2ZIZF+upBvOtSEjLWs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuhong Yuan , Hans Verkuil , Mauro Carvalho Chehab , Salvatore Bonaccorso Subject: [PATCH 4.19 235/267] media: go7007: fix a miss of snd_card_free Date: Fri, 19 Jun 2020 16:33:40 +0200 Message-Id: <20200619141659.979207377@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuhong Yuan commit 9453264ef58638ce8976121ac44c07a3ef375983 upstream. go7007_snd_init() misses a snd_card_free() in an error path. Add the missed call to fix it. Signed-off-by: Chuhong Yuan Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab [Salvatore Bonaccorso: Adjust context for backport to versions which do not contain c0decac19da3 ("media: use strscpy() instead of strlcpy()") and ba78170ef153 ("media: go7007: Fix misuse of strscpy")] Signed-off-by: Salvatore Bonaccorso Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/go7007/snd-go7007.c | 35 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) --- a/drivers/media/usb/go7007/snd-go7007.c +++ b/drivers/media/usb/go7007/snd-go7007.c @@ -244,22 +244,18 @@ int go7007_snd_init(struct go7007 *go) gosnd->capturing = 0; ret = snd_card_new(go->dev, index[dev], id[dev], THIS_MODULE, 0, &gosnd->card); - if (ret < 0) { - kfree(gosnd); - return ret; - } + if (ret < 0) + goto free_snd; + ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go, &go7007_snd_device_ops); - if (ret < 0) { - kfree(gosnd); - return ret; - } + if (ret < 0) + goto free_card; + ret = snd_pcm_new(gosnd->card, "go7007", 0, 0, 1, &gosnd->pcm); - if (ret < 0) { - snd_card_free(gosnd->card); - kfree(gosnd); - return ret; - } + if (ret < 0) + goto free_card; + strlcpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver)); strlcpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->driver)); strlcpy(gosnd->card->longname, gosnd->card->shortname, @@ -270,11 +266,8 @@ int go7007_snd_init(struct go7007 *go) &go7007_snd_capture_ops); ret = snd_card_register(gosnd->card); - if (ret < 0) { - snd_card_free(gosnd->card); - kfree(gosnd); - return ret; - } + if (ret < 0) + goto free_card; gosnd->substream = NULL; go->snd_context = gosnd; @@ -282,6 +275,12 @@ int go7007_snd_init(struct go7007 *go) ++dev; return 0; + +free_card: + snd_card_free(gosnd->card); +free_snd: + kfree(gosnd); + return ret; } EXPORT_SYMBOL(go7007_snd_init);