From patchwork Thu Aug 23 14:10:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1367401 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id EE3343FCAE for ; Thu, 23 Aug 2012 14:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932755Ab2HWOKN (ORCPT ); Thu, 23 Aug 2012 10:10:13 -0400 Received: from na3sys009aog126.obsmtp.com ([74.125.149.155]:53432 "EHLO na3sys009aog126.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932725Ab2HWOKM (ORCPT ); Thu, 23 Aug 2012 10:10:12 -0400 Received: from mail-ob0-f169.google.com ([209.85.214.169]) (using TLSv1) by na3sys009aob126.postini.com ([74.125.148.12]) with SMTP ID DSNKUDY5w43qt3DSllXoOwnts92XO2QdGAlJ@postini.com; Thu, 23 Aug 2012 07:10:12 PDT Received: by obhx4 with SMTP id x4so2038310obh.14 for ; Thu, 23 Aug 2012 07:10:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=R9b8CuF0O7WLhhcrN+90threhvypPIZRnyc4nuosrpA=; b=Ko/KTo+pMNoULWjsUnllUeMa8kd9XoRXgTAYYcGuWV/jWz2O6Evm4I1Q2UqjKrvHlU itlAXKEx+vGuU2JgJsgtpFLh1KjasIP6+EkyVTZDX14Jd1L3Rr/4oRGU5fgXQxaRNHtZ 27h3EPQe8JrVvB8hIlCzgL3Gvf/VdABA84QfUgibl8lXVU2KbNZyMbWQBE/1trorwKW2 mvLg7wrHmBCWDnFBBn3c2V6nYP/MZ2IqmnfSBZ2ToB2WhfNjz2xXvjmxjr6ElXVJ72QN ouIK6qJFbkqY60I05kn3jdBsyFsD1RHkmwHJHak8O0exJOy1MkAo15V7jisteeF/W1WW bKig== Received: by 10.60.30.168 with SMTP id t8mr1186932oeh.89.1345731011030; Thu, 23 Aug 2012 07:10:11 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id m3sm4927825oea.1.2012.08.23.07.10.07 (version=SSLv3 cipher=OTHER); Thu, 23 Aug 2012 07:10:09 -0700 (PDT) From: Peter Ujfalusi To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Tony Lindgren , Paul Walmsley , Kevin Hilman , Benoit Cousson Subject: [PATCH] driver core: Check if r->name is valid in platform_get_resource_byname() Date: Thu, 23 Aug 2012 17:10:00 +0300 Message-Id: <1345731000-12768-1-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.8.6 X-Gm-Message-State: ALoCoQmIlglJZraHn1eR70Wu7owcoEAK/M/2uLXIjRy4oHxWl6aI07tOHP9dU07uZkysFoNMjHCb Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Safety check for the validity of the resource name before calling strcmp(). If the resource name is NULL do not compare it, just skip it. Signed-off-by: Peter Ujfalusi --- Hi Greg, I have experienced with a kernel crash because the r->name was NULL when booting OMAP4+ kernel with devicetree. I have sent a separate patch for the OMAP specific root (with analysis of the issue): http://marc.info/?l=linux-omap&m=134573006327647&w=2 I agree that it is unlikely to have the name NULL, but I think it does not hurt if we do a safety check before comparing the strings. Best Regards, Peter drivers/base/platform.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index a1a7225..d717c2b 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -99,6 +99,9 @@ struct resource *platform_get_resource_byname(struct platform_device *dev, for (i = 0; i < dev->num_resources; i++) { struct resource *r = &dev->resource[i]; + if (unlikely(!r->name)) + continue; + if (type == resource_type(r) && !strcmp(r->name, name)) return r; }