Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp491265ybl; Tue, 28 Jan 2020 06:47:41 -0800 (PST) X-Google-Smtp-Source: APXvYqweYK+XwMS70izDsRkYogGmUuEK8hY0MJCQ1DWj0YsEixoJ3ob0aA/GkAAKHaIogq/er9Zw X-Received: by 2002:a05:6808:618:: with SMTP id y24mr2905431oih.86.1580222861416; Tue, 28 Jan 2020 06:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222861; cv=none; d=google.com; s=arc-20160816; b=tLGuwKksPCSkXbwhFM2zZoHP9DTvLDOC7/K0daPKnpRfpmAdXLgEbkp1AME0ItBN/+ 2Xt+/NM78XrYxgOq0RhOLgSiKR/paXcPCoXVW5BiEo63lirJbeJWzb93LtnudUUIc2ac tw6nthvAX9iDWkLymfZi8XQK3GfKjdok9W4VWvQx/7ApjHLmTmPOgZXBz/gdwNNc6VZP qW2zgK31eEPZAu0CGJ1+EJKe2/YSnwCx3bPZICJp0QxXhBiYK6oyW3s+bzVPPAi9oun7 09zJmq1oZaISqqP+mYrdZ8uUsEF/4ecWfkguN0J4Y7d4hNoPmE7JVe8f0WmTyyKlKSAz Oc/A== 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=KeW/dITVMzY2+4jX9PS8ymyXWVYrWO/LrWQMLiL4R/8=; b=zTrKdxWoVDVOwaRiYs0kMqXLAY+VUt5SbY09HWTPIm0UExhgYWLKvzMkuqUrQBJy4F cInOcaiveEegEyrquugY+upMF820Ci2hAJsza/T3Cjh83OqEhQNCflcWsEvfuRPeNYtL IFbcWPvByBYzk3mKezeOfEVbb7lG1VB2TrFhh5L7SGKynzw9HK1IruWA8VH21BSvEpYH PhKA3IwvPi7qGCeCHhZNYDSGOSfS/5/2nkkaDIBuf2NmLFd17dJBgEIwejPtn0iTo5m7 0lzAszh60UPWKrrOPj7/jF/8z/aNCKD1GJR9XUIWOOnsvjpII7jjYhiToUpP5XMShNMe 8VGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I5uyvvBL; 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 g72si3043031oib.157.2020.01.28.06.47.29; Tue, 28 Jan 2020 06:47:41 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=I5uyvvBL; 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 S1728091AbgA1OJu (ORCPT + 99 others); Tue, 28 Jan 2020 09:09:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:58264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729052AbgA1OJp (ORCPT ); Tue, 28 Jan 2020 09:09:45 -0500 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 32EA124688; Tue, 28 Jan 2020 14:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220584; bh=2wLAFD8Q/BkgaPwUDyunPTLaoG8N9NCstqyWYhtHsTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5uyvvBLwu7KMIpUTwM1wBX/UvNsfiylMI4+VWnhOs24ArZGu9JEOWLwTkGas36sh JQEb9r5HHOuvwOpvKbVUjBBdyz4pd8qgV6QkSo4+ykYj1D3OHTM81TSlg5OvrQ9WBK RqbiGqLdyTcWMmIeqkwhDn+XUgAkUHmIqGzrEQvw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Mc Guire , Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.4 064/183] media: cx23885: check allocation return Date: Tue, 28 Jan 2020 15:04:43 +0100 Message-Id: <20200128135836.395887091@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135829.486060649@linuxfoundation.org> References: <20200128135829.486060649@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: Nicholas Mc Guire [ Upstream commit a3d7f22ef34ec4206b50ee121384d5c8bebd5591 ] Checking of kmalloc() seems to have been committed - as cx23885_dvb_register() is checking for != 0 return, returning -ENOMEM should be fine here. While at it address the coccicheck suggestion to move to kmemdup rather than using kmalloc+memcpy. Fixes: 46b21bbaa8a8 ("[media] Add support for DViCO FusionHDTV DVB-T Dual Express2") Signed-off-by: Nicholas Mc Guire Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/cx23885/cx23885-dvb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index e543cbbf2ec4f..8fe78b8b1c25b 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -1452,8 +1452,9 @@ static int dvb_register(struct cx23885_tsport *port) if (fe0->dvb.frontend != NULL) { struct i2c_adapter *tun_i2c; - fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL); - memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops)); + fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL); + if (!fe0->dvb.frontend->sec_priv) + return -ENOMEM; tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1); if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config)) return -ENODEV; -- 2.20.1