From patchwork Fri May 30 10:20:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 31166 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3CDDD20671 for ; Fri, 30 May 2014 10:23:32 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id ma3sf6494353pbc.3 for ; Fri, 30 May 2014 03:23:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=TyUlraasXZcEOMUXeEPNl+NIuaK7c1dPHH3vZ2c59y4=; b=g6z+/bVQ6TsFtjsaxs4NdgGNCVs31mz6nUkQ+Gae7TXG6cupXsYkb1XnTZPombjh+v dDSKz/vIGkkXKliOo3/JA7JNO4m6XyOq4cyaEPB1vmJZDhDHtliHdueA962UXH5ng2TN u5pucqm4W4M7coAZuYMEBR7PjmMk+fudlDlXyOfid8KI8lGF4KpTvf9l0hDub8y2TWfm o4YSfoesgDCTP8O5K49qaN0hbQD1fQ6QMFIGop6QtDLNg6Vi9crmIv1vWV8DdnF9F9oU k7/rlTtQq9x6ciOMUdGSVMZj59OFdMRagmhxtT8dD3fLbWn4eMSKx+2UrgDyC67H+U/R UfSg== X-Gm-Message-State: ALoCoQlgMogsPpxWDnFdHe3jmym8koRe94zDMrgS1EaPSd5KkX7R0seJu/OMtCbBMnBzBkDT7S/N X-Received: by 10.66.219.104 with SMTP id pn8mr597675pac.2.1401445411481; Fri, 30 May 2014 03:23:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.138 with SMTP id 10ls950187qgx.9.gmail; Fri, 30 May 2014 03:23:31 -0700 (PDT) X-Received: by 10.53.12.229 with SMTP id et5mr10764067vdd.32.1401445411348; Fri, 30 May 2014 03:23:31 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id og7si2664618vcb.23.2014.05.30.03.23.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 03:23:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id il7so1601335vcb.8 for ; Fri, 30 May 2014 03:23:31 -0700 (PDT) X-Received: by 10.52.95.135 with SMTP id dk7mr10707952vdb.38.1401445411255; Fri, 30 May 2014 03:23:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp99896vcb; Fri, 30 May 2014 03:23:30 -0700 (PDT) X-Received: by 10.67.1.39 with SMTP id bd7mr17465286pad.15.1401445410459; Fri, 30 May 2014 03:23:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tk10si4895439pab.212.2014.05.30.03.23.29; Fri, 30 May 2014 03:23:29 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932903AbaE3KXU (ORCPT + 28 others); Fri, 30 May 2014 06:23:20 -0400 Received: from mail-pb0-f50.google.com ([209.85.160.50]:63870 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932816AbaE3KXR (ORCPT ); Fri, 30 May 2014 06:23:17 -0400 Received: by mail-pb0-f50.google.com with SMTP id ma3so1603194pbc.9 for ; Fri, 30 May 2014 03:23:17 -0700 (PDT) X-Received: by 10.68.218.231 with SMTP id pj7mr16899960pbc.95.1401445396961; Fri, 30 May 2014 03:23:16 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id dd5sm5615871pbc.85.2014.05.30.03.23.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 May 2014 03:23:16 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, maxime.ripard@free-electrons.com, sachin.kamat@linaro.org Subject: [PATCH 1/1] pinctrl: sunxi: Fix potential null pointer dereference Date: Fri, 30 May 2014 15:50:52 +0530 Message-Id: <1401445252-21413-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , kzalloc can fail. Add a null check to avoid null pointer dereference error while accessing the pointer later. Signed-off-by: Sachin Kamat Acked-by: Maxime Ripard --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index f1ca75e6d7b1..5f38c7f67834 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -211,6 +211,10 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, configlen++; pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL); + if (!pinconfig) { + kfree(*map); + return -ENOMEM; + } if (!of_property_read_u32(node, "allwinner,drive", &val)) { u16 strength = (val + 1) * 10;