From patchwork Fri Jul 19 14:10:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 18451 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6163826EE8 for ; Fri, 19 Jul 2013 14:10:31 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id w16sf5510938vbb.4 for ; Fri, 19 Jul 2013 07:10:31 -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 :in-reply-to:references: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=s8dESqBtK9UwXOogoTDTCDmRwGwOso7tIWloTjVfiRs=; b=ET4EtQmLQKqfaiiSR6OeYvz8FY8gDzL7mZZkS1go23qVFDhRtKPP5AmVW1ZOMocFp+ SIvPQkxMlD562LPu03/o0fXABgThUK18HbZ/u/ZdsZnlXDl8ZYG2aege6KRQbICsDyWL 9MdEV35dx4U9uoZeTDCx98mZibwDvQbrcRSpMuHHHYVIKm1Me8PRSSr9/O38aTc+Uomx ybYkZrqAVmts3XCgFsB7wzYvJHll7nsewijh2eAxxAj/1NKRff3uSjhR1SMpPniHD985 b9K5NtQs04GhEZ5BUoV+LbKSK1DbJihAaYJzzUN02VJSGfGAHbmRixUrzVJNzY2iirbO TnZQ== X-Received: by 10.236.119.107 with SMTP id m71mr9067342yhh.0.1374243031121; Fri, 19 Jul 2013 07:10:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.26.137 with SMTP id l9ls1737392qeg.35.gmail; Fri, 19 Jul 2013 07:10:31 -0700 (PDT) X-Received: by 10.52.249.9 with SMTP id yq9mr4932293vdc.93.1374243030990; Fri, 19 Jul 2013 07:10:30 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id tf3si4069363vec.68.2013.07.19.07.10.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 07:10:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id c13so3463363vea.35 for ; Fri, 19 Jul 2013 07:10:30 -0700 (PDT) X-Received: by 10.220.83.69 with SMTP id e5mr3235669vcl.53.1374243030909; Fri, 19 Jul 2013 07:10:30 -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 yu8csp27252veb; Fri, 19 Jul 2013 07:10:30 -0700 (PDT) X-Received: by 10.15.81.136 with SMTP id x8mr16266115eey.4.1374243029665; Fri, 19 Jul 2013 07:10:29 -0700 (PDT) Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com [74.125.83.45]) by mx.google.com with ESMTPS id j47si14160404eeo.200.2013.07.19.07.10.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 07:10:29 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.45 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.45; Received: by mail-ee0-f45.google.com with SMTP id c1so2419091eek.18 for ; Fri, 19 Jul 2013 07:10:29 -0700 (PDT) X-Received: by 10.14.209.197 with SMTP id s45mr16251455eeo.108.1374243029143; Fri, 19 Jul 2013 07:10:29 -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.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Jul 2013 07:10:28 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: sameo@linux.intel.com, Lee Jones Subject: [PATCH 2/3] mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for event name Date: Fri, 19 Jul 2013 15:10:16 +0100 Message-Id: <1374243017-8515-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1374243017-8515-1-git-send-email-lee.jones@linaro.org> References: <1374243017-8515-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQliTVhoQvlSM3btH10gm2QED0qbBGiLak3B/c9WHbuPswv5fBSc3qZ0hjiDxVHwP10LZniV X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 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 to contain the name of 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 address NULL with the specified device name 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 c8298b2..30fcb0c 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -2804,6 +2804,9 @@ static ssize_t ab8500_subscribe_write(struct file *file, return -ENOMEM; event_name[irq_index] = kmalloc(count, GFP_KERNEL); + if (!event_name[irq_index]) + return -ENOMEM; + sprintf(event_name[irq_index], "%lu", user_val); dev_attr[irq_index]->show = show_irq; dev_attr[irq_index]->store = NULL;