Received: by 10.223.164.202 with SMTP id h10csp2882592wrb; Tue, 28 Nov 2017 02:56:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMaLa8j483zaT6rU60MyX1q0k60t/rGWWvrN3JZOwdv4jTaYHwTo46yAJsm3bIS/duFmEoMf X-Received: by 10.84.215.146 with SMTP id l18mr28159491pli.451.1511866607053; Tue, 28 Nov 2017 02:56:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511866607; cv=none; d=google.com; s=arc-20160816; b=Nvf7XnJhzTxjkK4OkOcZigU6lKIupxzlUBNz4fOspA5AMweybIVE3RRu5lUDq51Sz9 5swZQKZBSckot6pvlnn0v0sZHo5mqcHLKpcpOe/+4Tq+i+96IeNKdOMI/Q51ZlRERTdx OpcsCkABl5E1F0Q3Vi5eHRxta/nW3cYeSqqxqH/oMLwluFTJZJQtXbhDaWQSdfZI83rS f2Pd5xLK+idRBXuLAxsfzHBP/2w1/gaUBykJRkZL4yn8KhUu6Ry5fkUfyK10mkoSNogU fR6sJ+z165df5/kaRP4uuW91xHmvi4jbvQFtGLZcF1QMKNrkdHHAcLKIuIQPjMf2++bS oZwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=/Zd3gmhTOEtgISNcKnBPR+/qbg8K5JrzP8jSefFVcTY=; b=hXo79temCON1XjEFP7hj49s96KrVMDEigdJ5IlLFdB7h1IzqCuWnvYbsy36fEsRkew l969zMkRCP7LG9U0CHg9rcql97q+S1qHiqKp35oocAoUE41MLNx5C9NOPVy7rvm1Lcum ouBj2xfpBlb8t+J6zycOqJ7UiWM1inIgr01iYuHbc/VLSHz91owhBIyQP7X0frtsYZCN uXaieHJy36gA9XR6oX/aRDjleXadYdPsQMYF02yNtZwiJxeCY79GEMvuh0fIf/ImUs9F daAcbLizNQDvJwNhSQfTyudwsr5shkVR8Ec4NclRXbxQl0GN+RILu8fnE3kAwiwYABYN RrJw== 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 x33si3357123plb.374.2017.11.28.02.56.35; Tue, 28 Nov 2017 02:56:47 -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; 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 S1755273AbdK1Kz2 (ORCPT + 79 others); Tue, 28 Nov 2017 05:55:28 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:60950 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932214AbdK1KzZ (ORCPT ); Tue, 28 Nov 2017 05:55:25 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23991258AbdK1KXc45MRm (ORCPT + 3 others); Tue, 28 Nov 2017 11:23:32 +0100 Date: Tue, 28 Nov 2017 11:23:27 +0100 From: Ladislav Michl To: SF Markus Elfring Cc: Julia Lawall , linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Joe Perches , "Andrew F. Davis" , Arvind Yadav , Bartlomiej Zolnierkiewicz , Tomi Valkeinen , LKML , kernel-janitors@vger.kernel.org Subject: Re: omapfb/dss: Delete an error message for a failed memory allocation in three functions Message-ID: <20171128102327.GA30267@lenoch> References: <1511809633.32426.70.camel@perches.com> <1511833514.32426.86.camel@perches.com> <7e7e64cf-dbe5-614a-f1e5-29d7b6cf9297@users.sourceforge.net> <1511856244.19952.14.camel@perches.com> <0ecf4b17-7757-adb4-b978-a80ebb15cfe6@users.sourceforge.net> <28816ce9-9d62-7d61-1889-64407eececca@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <28816ce9-9d62-7d61-1889-64407eececca@users.sourceforge.net> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 28, 2017 at 11:15:37AM +0100, SF Markus Elfring wrote: > >>> Many people do not know that a generic kmalloc does a > >>> dump_stack() on OOM. > >> > >> This is another interesting information, isn't it? > >> > >> It is expected that the function “devm_kzalloc” has got a similar property. > > > > > > You don't have to expect this. Go look at the definition of devm_kzalloc > > and see whether it has the property or not. > > I find that the corresponding documentation of these programming interfaces > is incomplete for a desired format which could be different than C source code. > > https://elixir.free-electrons.com/linux/v4.15-rc1/source/include/linux/device.h#L657 > https://elixir.free-electrons.com/linux/v4.15-rc1/source/drivers/base/devres.c#L763 > https://www.kernel.org/doc/html/latest/driver-api/basics.html#c.devm_kmalloc > > Can the Coccinelle software help more to determine desired function properties? > > > >> For which hardware and software combinations would you like to see > >> facts there? > > > > This is not for Joe to decide, > > This view is fine in principle. > > > > it's for the person who receives the patch to decide. > > I am curious on further comments from these contributors. > > > > You could start with the ones for which the code actually compiles, > > using the standard make file and no special options, and a > > recent version of gcc. > > The variation space could become too big to handle for me (alone). > How will this aspect evolve further? I do not follow. This is OMAP framebuffer driver, so in this case, there is zero variation. Could you, please, review following patch and verify is it satisfies your automated static code analysis test? diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c index 7a75dfda9845..6be13a106ece 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c @@ -3976,52 +3976,33 @@ static const struct dispc_features omap54xx_dispc_feats = { .has_writeback = true, }; -static int dispc_init_features(struct platform_device *pdev) +static const struct dispc_features* dispc_get_features(void) { - const struct dispc_features *src; - struct dispc_features *dst; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate DISPC Features\n"); - return -ENOMEM; - } - switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP24xx: - src = &omap24xx_dispc_feats; - break; + return &omap24xx_dispc_feats; case OMAPDSS_VER_OMAP34xx_ES1: - src = &omap34xx_rev1_0_dispc_feats; - break; + return &omap34xx_rev1_0_dispc_feats; case OMAPDSS_VER_OMAP34xx_ES3: case OMAPDSS_VER_OMAP3630: case OMAPDSS_VER_AM35xx: case OMAPDSS_VER_AM43xx: - src = &omap34xx_rev3_0_dispc_feats; - break; + return &omap34xx_rev3_0_dispc_feats; case OMAPDSS_VER_OMAP4430_ES1: case OMAPDSS_VER_OMAP4430_ES2: case OMAPDSS_VER_OMAP4: - src = &omap44xx_dispc_feats; - break; + return &omap44xx_dispc_feats; case OMAPDSS_VER_OMAP5: case OMAPDSS_VER_DRA7xx: - src = &omap54xx_dispc_feats; - break; + return &omap54xx_dispc_feats; default: - return -ENODEV; + return NULL; } - - memcpy(dst, src, sizeof(*dst)); - dispc.feat = dst; - - return 0; } static irqreturn_t dispc_irq_handler(int irq, void *arg) @@ -4078,9 +4059,9 @@ static int dispc_bind(struct device *dev, struct device *master, void *data) spin_lock_init(&dispc.control_lock); - r = dispc_init_features(dispc.pdev); - if (r) - return r; + dispc.feat = dispc_get_features(); + if (!dispc.feat) + return -ENODEV; dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); if (!dispc_mem) { diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c b/drivers/video/fbdev/omap2/omapfb/dss/dss.c index 48c6500c24e1..9a255ffe77c5 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c @@ -887,58 +887,37 @@ static const struct dss_features dra7xx_dss_feats = { .num_ports = ARRAY_SIZE(dra7xx_ports), }; -static int dss_init_features(struct platform_device *pdev) +static const struct dss_features* dss_get_features(void) { - const struct dss_features *src; - struct dss_features *dst; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate local DSS Features\n"); - return -ENOMEM; - } - switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP24xx: - src = &omap24xx_dss_feats; - break; + return &omap24xx_dss_feats; case OMAPDSS_VER_OMAP34xx_ES1: case OMAPDSS_VER_OMAP34xx_ES3: case OMAPDSS_VER_AM35xx: - src = &omap34xx_dss_feats; - break; + return &omap34xx_dss_feats; case OMAPDSS_VER_OMAP3630: - src = &omap3630_dss_feats; - break; + return &omap3630_dss_feats; case OMAPDSS_VER_OMAP4430_ES1: case OMAPDSS_VER_OMAP4430_ES2: case OMAPDSS_VER_OMAP4: - src = &omap44xx_dss_feats; - break; + return &omap44xx_dss_feats; case OMAPDSS_VER_OMAP5: - src = &omap54xx_dss_feats; - break; + return &omap54xx_dss_feats; case OMAPDSS_VER_AM43xx: - src = &am43xx_dss_feats; - break; + return &am43xx_dss_feats; case OMAPDSS_VER_DRA7xx: - src = &dra7xx_dss_feats; - break; + return &dra7xx_dss_feats; default: - return -ENODEV; + return NULL; } - - memcpy(dst, src, sizeof(*dst)); - dss.feat = dst; - - return 0; } static void dss_uninit_ports(struct platform_device *pdev); @@ -1104,9 +1083,9 @@ static int dss_bind(struct device *dev) dss.pdev = pdev; - r = dss_init_features(dss.pdev); - if (r) - return r; + dss.feat = dss_get_features(); + if (!dss.feat) + return -ENODEV; dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); if (!dss_mem) { diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c index 9a13c35fd6d8..07d46e14cea4 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi_phy.c @@ -189,47 +189,30 @@ static const struct hdmi_phy_features omap54xx_phy_feats = { .max_phy = 186000000, }; -static int hdmi_phy_init_features(struct platform_device *pdev) +static const struct hdmi_phy_features* hdmi_phy_get_features(void) { - struct hdmi_phy_features *dst; - const struct hdmi_phy_features *src; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate HDMI PHY Features\n"); - return -ENOMEM; - } - switch (omapdss_get_version()) { case OMAPDSS_VER_OMAP4430_ES1: case OMAPDSS_VER_OMAP4430_ES2: case OMAPDSS_VER_OMAP4: - src = &omap44xx_phy_feats; - break; + return &omap44xx_phy_feats; case OMAPDSS_VER_OMAP5: case OMAPDSS_VER_DRA7xx: - src = &omap54xx_phy_feats; - break; + return &omap54xx_phy_feats; default: - return -ENODEV; + return NULL; } - - memcpy(dst, src, sizeof(*dst)); - phy_feat = dst; - - return 0; } int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) { - int r; struct resource *res; - r = hdmi_phy_init_features(pdev); - if (r) - return r; + phy_feat = hdmi_phy_get_features(); + if (!phy_feat) + return -ENODEV; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); if (!res) { From 1585304625520356822@xxx Tue Nov 28 10:18:25 +0000 2017 X-GM-THRID: 1585156039807309629 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread