From patchwork Sat Jun 21 15:57:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HIMANGI SARAOGI X-Patchwork-Id: 4394421 Return-Path: X-Original-To: patchwork-linux-fbdev@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 31C08BEEAA for ; Sat, 21 Jun 2014 15:58:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51CD220253 for ; Sat, 21 Jun 2014 15:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34A5A2020A for ; Sat, 21 Jun 2014 15:58:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753116AbaFUP6J (ORCPT ); Sat, 21 Jun 2014 11:58:09 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:50466 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752772AbaFUP6I (ORCPT ); Sat, 21 Jun 2014 11:58:08 -0400 Received: by mail-pa0-f49.google.com with SMTP id lj1so4160475pab.22 for ; Sat, 21 Jun 2014 08:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=SMG1PqwVVnGgHPEXNlDbhk4LzLHvCPE3FT8o8Z3KouY=; b=BaYhg2QrSna/Gx2a2uEoGptGjE2pt2cXPupIOVr8NYXb6UBO3VjFasIuRCUKP21ffQ Nob6V4ZDtPxtb2+K91AyCd1KzcslAqNOBE3KvqOgNxxsGymhlSnZZfWb/B3E2mI0Cexj L2Ie7FrOXWQ42RFfFrdVZRYTrbxuF7o5H/ltrQscIjq+9dr6bem4HaNM6A7qSJjSBVpv tpUi+bujncpK/nPXmmW1fgS+ad3mxyycSGwNcfseiMUnVwlZbnpB/rguv7LujWaTyQB4 jzXLwcMyaP8cyso0UjpPr0i2sqROPSK0VLDU9FZMwQdkaQMd7UK5MmJW11PjUjcZF+Rp pBhw== X-Received: by 10.68.186.33 with SMTP id fh1mr14010253pbc.140.1403366288404; Sat, 21 Jun 2014 08:58:08 -0700 (PDT) Received: from localhost ([42.104.13.160]) by mx.google.com with ESMTPSA id y2sm62015706pas.45.2014.06.21.08.58.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Jun 2014 08:58:07 -0700 (PDT) Date: Sat, 21 Jun 2014 21:27:59 +0530 From: Himangi Saraogi To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr Subject: [PATCH] drivers/video/fbdev : dereference without an error test Message-ID: <20140621155758.GA4741@himangi-Dell> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 After a variable is assigned the result of backlight_device_register, an error test should be performed before a dereference. A simplified version of the semantic match that finds this problem is as follows: // @def0@ expression x; position p0; @@ x@p0 = backlight_device_register(...) @protected@ expression def0.x,E; position def0.p0; position p; statement S; @@ x@p0 ... when != x = E if (!IS_ERR(x) && ...) {<... x@p ...>} else S @unprotected@ expression def0.x,E; identifier fld; position def0.p0; position p != protected.p; @@ x@p0 ... when != x = E * x@p->fld // Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall --- drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c index c7ba4d8..acd9ff1 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c @@ -817,6 +817,10 @@ static int acx565akm_probe(struct spi_device *spi) bldev = backlight_device_register("acx565akm", &ddata->spi->dev, ddata, &acx565akm_bl_ops, &props); + if (IS_ERR(bldev)) { + r = PTR_ERR(bldev); + goto err_reg; + } ddata->bl_dev = bldev; if (ddata->has_cabc) { r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group); @@ -862,6 +866,7 @@ err_reg: sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group); err_sysfs: backlight_device_unregister(bldev); +err_reg: err_detect: err_gpio: omap_dss_put_device(ddata->in);