From patchwork Fri Jul 19 14:10:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 18450 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A56325E49 for ; Fri, 19 Jul 2013 14:10:29 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id d10sf5997604vea.0 for ; Fri, 19 Jul 2013 07:10:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=y6r1bJj7uhU2IWbq72sGqX+1k3zcr2xjesucoAjLC0w=; b=Qdr12rotHO8mF8aFu2+eDSkKf5JERlxyTwce67Lo9yvT8agyYB/rqCfZ2s44U0Bih2 Or7GhqBYH8nPXo7saQzLUYSlMG8fXK4lNQyQBjG/uRTJOYFiksbrhLNImKlEPUJH25UJ FWE63zOHPrkuPF7vAQX/H6QdbKgqHh7UznNwbQQLxyG+iJObqSy1ohpQLtEJ9owsHZdp qgErsJvvQdmIAkIAqXpF7ThHsREIRIhtd8gbxMm/WrNSfKtC54StCEim3nHm0e+OCTh8 5i1TjBMeIA/gZIBDRxvb3vCQ4UfdQiyg9cjoBvtO9umSIOaQ1MQvPzfTY+OfxpjE3Z0I ru9Q== X-Received: by 10.236.125.200 with SMTP id z48mr8928042yhh.55.1374243028305; Fri, 19 Jul 2013 07:10:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.82.136 with SMTP id i8ls1812687qey.37.gmail; Fri, 19 Jul 2013 07:10:28 -0700 (PDT) X-Received: by 10.221.4.138 with SMTP id oc10mr5939860vcb.26.1374243028168; Fri, 19 Jul 2013 07:10:28 -0700 (PDT) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id a1si4067720vek.83.2013.07.19.07.10.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 07:10:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id x14so3238762vbb.34 for ; Fri, 19 Jul 2013 07:10:28 -0700 (PDT) X-Received: by 10.52.35.109 with SMTP id g13mr4855511vdj.21.1374243028099; Fri, 19 Jul 2013 07:10:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp27248veb; Fri, 19 Jul 2013 07:10:27 -0700 (PDT) X-Received: by 10.14.211.67 with SMTP id v43mr16297237eeo.55.1374243027038; Fri, 19 Jul 2013 07:10:27 -0700 (PDT) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by mx.google.com with ESMTPS id s8si14131828ees.328.2013.07.19.07.10.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 07:10:27 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.42 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.42; Received: by mail-ee0-f42.google.com with SMTP id c4so2384873eek.15 for ; Fri, 19 Jul 2013 07:10:26 -0700 (PDT) X-Received: by 10.15.54.67 with SMTP id s43mr16166655eew.133.1374243026513; Fri, 19 Jul 2013 07:10:26 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPSA id m1sm27644902eex.17.2013.07.19.07.10.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 07:10:25 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: sameo@linux.intel.com, Lee Jones Subject: [PATCH 1/3] mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for sysfs Date: Fri, 19 Jul 2013 15:10:15 +0100 Message-Id: <1374243017-8515-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-Gm-Message-State: ALoCoQmxFA4zAuDj3qiMjH0qmJENFmBdOj7cZYgAQWJO1gpRDXJSZRvZR/A726B+84uR+0RkUKuq X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The AB8500 debugfs driver allocates memory for a new sysfs entry, but fails to apply the proper post-allocation checks. If the device were to run out of memory, the allocation would return NULL. Without the correct checks the driver will continue to populate NULL->[show|store|...], which would obviously cause a pointer dereference Oops. Signed-off-by: Lee Jones --- drivers/mfd/ab8500-debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 7d1f1b0..c8298b2 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -2800,6 +2800,9 @@ static ssize_t ab8500_subscribe_write(struct file *file, */ dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), GFP_KERNEL); + if (!dev_attr[irq_index]) + return -ENOMEM; + event_name[irq_index] = kmalloc(count, GFP_KERNEL); sprintf(event_name[irq_index], "%lu", user_val); dev_attr[irq_index]->show = show_irq;