From patchwork Mon Oct 27 14:31:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 5161271 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70BA4C11AC for ; Mon, 27 Oct 2014 14:31:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA4A8201BC for ; Mon, 27 Oct 2014 14:31:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3D402017E for ; Mon, 27 Oct 2014 14:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753165AbaJ0Obe (ORCPT ); Mon, 27 Oct 2014 10:31:34 -0400 Received: from mailout3.w2.samsung.com ([211.189.100.13]:56120 "EHLO usmailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752920AbaJ0Obd (ORCPT ); Mon, 27 Oct 2014 10:31:33 -0400 Received: from uscpsbgm1.samsung.com (u114.gpu85.samsung.co.kr [203.254.195.114]) by usmailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NE300F5JXOK8860@usmailout3.samsung.com> for linux-media@vger.kernel.org; Mon, 27 Oct 2014 10:31:32 -0400 (EDT) X-AuditID: cbfec372-b7f666d000001846-61-544e5744a69a Received: from ussync4.samsung.com ( [203.254.195.84]) by uscpsbgm1.samsung.com (USCPMTA) with SMTP id 2F.B5.06214.4475E445; Mon, 27 Oct 2014 10:31:32 -0400 (EDT) Received: from recife.lan ([105.144.34.5]) by ussync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NE3002BDXOHIM50@ussync4.samsung.com>; Mon, 27 Oct 2014 10:31:32 -0400 (EDT) Date: Mon, 27 Oct 2014 12:31:28 -0200 From: Mauro Carvalho Chehab To: tskd08@gmail.com Cc: linux-media@vger.kernel.org Subject: Re: [PATCH v2 1/7] v4l-utils/libdvbv5: fix auto generation of channel names Message-id: <20141027123128.45aff774.m.chehab@samsung.com> In-reply-to: <1414323983-15996-2-git-send-email-tskd08@gmail.com> References: <1414323983-15996-1-git-send-email-tskd08@gmail.com> <1414323983-15996-2-git-send-email-tskd08@gmail.com> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.24; x86_64-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t/hEF2XcL8Qg4lHVSx6NmxltVhzdi+j A5PHzll32T0+b5ILYIrisklJzcksSy3St0vgyug+WFIwXaRi8reVjA2Mx/m7GDk5JARMJH6v /c4KYYtJXLi3nq2LkYtDSGAJo8TjtY3MEE4Dk8SrX5vZQapYBFQlrsxqZQax2QSMJF41toB1 iwiISDS9XMQGYjMLyEvMv3SYBcQWFgiTmLX7Jlg9r4CVxPOrH5i6GDk4OAUcJW72gZUICZRL tO44xQoSlhBwlpj/ORuiWlDix+R7LBATtSQ2b2tihZm+ec1b5gmMArOQlM1CUjYLSdkCRuZV jKKlxckFxUnpuYZ6xYm5xaV56XrJ+bmbGCEBWbSD8dkGq0OMAhyMSjy8lV98Q4RYE8uKK3MP MUpwMCuJ8J4K8AsR4k1JrKxKLcqPLyrNSS0+xMjEwSnVwMi5LOKjgqCjYMWiZS6GJ5+vzTZy UnGdd7djt2Zbd8KzY6t/nb+yN6g5VclZWOmbvcDSsBm1XDq68o/EHCKZOd9NyHtWN+dlRFHS pa3njud+Ynfem9lzL1Z3+u23X1RYCwyPcTz6u66qWmv1iTUfK4s7nvba10opbV3bdO2j7ptq 7eCl0wt2HVViKc5INNRiLipOBABEvZX+JgIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Em Sun, 26 Oct 2014 20:46:17 +0900 tskd08@gmail.com escreveu: > From: Akihiro Tsukada > > when channel name was not available, it was generated from unset variables, > and leaked memory. > --- > lib/libdvbv5/dvb-file.c | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-) I suspect that you're using an older version of the git respository. The patch didn't apply. After forcing it, the patch became the enclosed change. I suspect, however, that this will actually cause a core dump, as get_program_and_store() is called with a NULL parameter for channel, when !SDT. Are you sure that such memory leak still happens with the current version? I remember I tested it with valgrind and was unable to find any case where a memory leak was happening. For now, I'll be just applying this change on a separate patch: - r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id); + r = asprintf(&channel, "%.2f%cHz#%d", freq / 1000000., + dvb_fe_is_satellite(parms->p.current_sys) ? 'G' : 'M', + service_id); If you're still noticing this bug, please send a fix against the latest upstream version. Regards, Mauro --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib/libdvbv5/dvb-file.c b/lib/libdvbv5/dvb-file.c index 479f47eda862..bbed60832e92 100644 --- a/lib/libdvbv5/dvb-file.c +++ b/lib/libdvbv5/dvb-file.c @@ -1141,8 +1141,11 @@ static int get_program_and_store(struct dvb_v5_fe_parms_priv *parms, if (!channel && entry->props[j].cmd == DTV_FREQUENCY) freq = parms->dvb_prop[j].u.data; } - if (!channel) { - r = asprintf(&channel, "%.2fMHz#%d", freq/1000000., service_id); + if (!*channel) { + free(channel); + r = asprintf(&channel, "%.2f%cHz#%d", freq / 1000000., + dvb_fe_is_satellite(parms->p.current_sys) ? 'G' : 'M', + service_id); if (r < 0) dvb_perror("asprintf"); dvb_log("Storing Service ID %d: '%s'", service_id, channel); @@ -1240,13 +1243,20 @@ int dvb_store_channel(struct dvb_file **dvb_file, if (!warned) { dvb_log("WARNING: no SDT table - storing channel(s) without their names"); warned = 1; + + rc = asprintf(&channel, "#%d", service_id); + if (rc < 0) { + dvb_perror("asprintf"); + return rc; } rc = get_program_and_store(parms, *dvb_file, dvb_scan_handler, service_id, NULL, NULL, get_detected, get_nit); - if (rc < 0) + if (rc < 0) { + free(channel); return rc; + } } return 0;