From patchwork Mon Dec 16 21:32:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22542 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5354429BB4 for ; Mon, 16 Dec 2013 21:32:56 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id a41sf10483062yho.8 for ; Mon, 16 Dec 2013 13:32:56 -0800 (PST) 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:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=nHnMNlaAAsv4H5KIopZePOM3GK60l2edFfIAUR6LqF0=; b=aqUuMEjbjLfpUvkEBlgsjfpUaMOJkL0Jl05XfkSIoDvSnzLIii9ukkQISsIe1soBNC eNYFtdvI9Govfy2g7NWIzXKyw9X7uPOtV/zAPZFyKlXPHw2/NoANjpK/HDME6Yn6i9Bf SoD4vROcPBueG4U6B/aVBwuTgecoZpMkIZ2RVKROAI34y7Djv8eO9TC2p5SH4hJPiZFx ksvKy9R6S2YWyqRQz1mzpKe/85NvwJE7q5FYo/7cBCHoxwjkjnkGkbMZP46J3TlSdz8n d8pPeRS0jvF6LQUdWCKg86HJMqIwxNtSCfRjkzwbCmWMAxL6g+4ckyKEjad0MaR5GkYE gjiw== X-Gm-Message-State: ALoCoQkQSUXBU1d1R1ADADjvPOkG+77+dlCZz7iTiZRY6AbSBqEz5pihVr+dDV8qB/h5903VWm+y X-Received: by 10.58.221.98 with SMTP id qd2mr6363634vec.5.1387229576151; Mon, 16 Dec 2013 13:32:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.163 with SMTP id p3ls2247343qed.41.gmail; Mon, 16 Dec 2013 13:32:56 -0800 (PST) X-Received: by 10.58.108.196 with SMTP id hm4mr4823011veb.28.1387229576054; Mon, 16 Dec 2013 13:32:56 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id gx6si4283577vdc.37.2013.12.16.13.32.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 13:32:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ia6so3583960vcb.18 for ; Mon, 16 Dec 2013 13:32:56 -0800 (PST) X-Received: by 10.58.11.73 with SMTP id o9mr9256630veb.8.1387229575969; Mon, 16 Dec 2013 13:32:55 -0800 (PST) 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.220.174.196 with SMTP id u4csp20316vcz; Mon, 16 Dec 2013 13:32:55 -0800 (PST) X-Received: by 10.68.106.98 with SMTP id gt2mr22863993pbb.61.1387229575222; Mon, 16 Dec 2013 13:32:55 -0800 (PST) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id za5si9946165pbc.189.2013.12.16.13.32.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 13:32:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id md12so5973102pbc.5 for ; Mon, 16 Dec 2013 13:32:54 -0800 (PST) X-Received: by 10.68.164.165 with SMTP id yr5mr22962738pbb.146.1387229574852; Mon, 16 Dec 2013 13:32:54 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id nl7sm26678363pbc.6.2013.12.16.13.32.53 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 13:32:54 -0800 (PST) From: John Stultz To: LKML Cc: John Stultz , Colin Cross , Greg KH , Android Kernel Team , kbuild test robot Subject: [RFC][PATCH 2/3] staging: ion: Fix possible null pointer dereference Date: Mon, 16 Dec 2013 13:32:43 -0800 Message-Id: <1387229564-19517-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1387229564-19517-1-git-send-email-john.stultz@linaro.org> References: <1387229564-19517-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 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 kbuild test robot reported: drivers/staging/android/ion/ion_system_heap.c:122 alloc_largest_available() error: potential null dereference 'info'. (kmalloc returns null) Where the pointer returned from kmalloc goes unchecked for failure. This patch adds a simple check for a null return, and handles the error. XXX: Not sure if continue or 'return NULL' is the right thing to do. Cc: Colin Cross Cc: Greg KH Cc: Android Kernel Team Cc: kbuild test robot Reported-by: kbuild test robot Signed-off-by: John Stultz --- drivers/staging/android/ion/ion_system_heap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 144b2272..cc2e4da 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -119,6 +119,11 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap, continue; info = kmalloc(sizeof(struct page_info), GFP_KERNEL); + if(!info) { + free_buffer_page(heap, buffer, page, orders[i]); + continue; + } + info->page = page; info->order = orders[i]; return info;