From patchwork Tue Sep 18 08:48:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11493 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7C39923E01 for ; Tue, 18 Sep 2012 08:52:34 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0A6F83D09237 for ; Tue, 18 Sep 2012 08:52:33 +0000 (UTC) Received: by ieak11 with SMTP id k11so10545494iea.11 for ; Tue, 18 Sep 2012 01:52:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=cFJ26mghYLtFwiOOeeK7qOiIiwdd8TU9oDOJTjx0RzA=; b=K7Xyb4RAZ/IIAKHzWmLj5YyOx0BADBlgg5s3npeCZalD4TZqiL9k0P55YX8tQD7t3H Xv1egofIFwpXld59dXoPDqn0EpIm2WITfLObFdT5Yjt6HcxUrnHZ+HCEuazewHR2Rt7e 3jZThjSF1DrEC39JKCP/ZV6MOtDTZetXsAPH0EjAo0wItWxCLyduKeCvpW+CqE3dtDYM S/mbzKzcuUkOzC1ogfRu/8DY8jSNjwKPH/bTP/y3WCThWFwVE6swUYqvJtry9fTOiIy0 TkwBltcrki/4QqbuHmmjv1wQPPvBuLmi+VBLqtyVc6QFGL9SNK7F2h2C1KuFn/fD6Tbc QJ4g== Received: by 10.50.191.227 with SMTP id hb3mr9610374igc.43.1347958353297; Tue, 18 Sep 2012 01:52:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp362054igc; Tue, 18 Sep 2012 01:52:32 -0700 (PDT) Received: by 10.66.79.38 with SMTP id g6mr25081726pax.40.1347958352333; Tue, 18 Sep 2012 01:52:32 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id r3si227403pay.308.2012.09.18.01.52.31 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Sep 2012 01:52:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by pbcmd12 with SMTP id md12so12170234pbc.37 for ; Tue, 18 Sep 2012 01:52:31 -0700 (PDT) Received: by 10.68.192.7 with SMTP id hc7mr198153pbc.6.1347958351480; Tue, 18 Sep 2012 01:52:31 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id uu10sm8323858pbc.2.2012.09.18.01.52.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Sep 2012 01:52:30 -0700 (PDT) From: Sachin Kamat To: linux-i2c@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org, sachin.kamat@linaro.org, patches@linaro.org, Wolfram Sang , Grant Likely , Rob Herring Subject: [PATCH] i2c-s3c2410: Fix potential NULL pointer dereference Date: Tue, 18 Sep 2012 14:18:48 +0530 Message-Id: <1347958128-13146-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQmYHIAN1ohO1UgEYTLDzZeCDsvHZnQkf4O+55OAOpWI+oz+q5MfUMU9/OwKEbLoIeReWtVU of_match_node() returns NULL if a device_node does not have a matching of_match structure. Thus the return value needs to be checked for NULL to avoid NULL pointer dereferencing. Cc: Wolfram Sang Cc: Grant Likely Cc: Rob Herring Signed-off-by: Sachin Kamat --- drivers/i2c/busses/i2c-s3c2410.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 5ae3b02..d906523 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -123,6 +123,8 @@ static inline unsigned int s3c24xx_get_device_quirks(struct platform_device *pde if (pdev->dev.of_node) { const struct of_device_id *match; match = of_match_node(s3c24xx_i2c_match, pdev->dev.of_node); + if (!match) + return 0; return (unsigned int)match->data; }