From patchwork Tue Jan 28 14:04:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC3D0C2D0DB for ; Tue, 28 Jan 2020 14:09:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6AE022522 for ; Tue, 28 Jan 2020 14:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220587; bh=2wLAFD8Q/BkgaPwUDyunPTLaoG8N9NCstqyWYhtHsTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CqUXUA+iqR1bgpXRy/BRJx4hK67GI6DZGEEVtmtUx4vzyALi1ON3XYZvqidYyPRfP 4weccokOhAPYESew7BdGAiR1TmS1Boq7fQA73TDyEKX9+rQrDrvZe4hg0aGv6fVcOq DaBKSkyMvqQAjSOoK+l6xEkHUtOwOMe1Aav8uhuI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728102AbgA1OJq (ORCPT ); Tue, 28 Jan 2020 09:09:46 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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;