From patchwork Tue Oct 29 22:55:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 21270 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 01A8E25E1B for ; Tue, 29 Oct 2013 22:55:34 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id tp5sf1621242ieb.1 for ; Tue, 29 Oct 2013 15:55:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=jHkVZ+7x4f7T4ZRH8Cz5FChzXjaitJjlBliEjTHjoNQ=; b=YwP3AVKhb52hzmLw+KgpnEh0gVKvjytIT4EG53NeEbSO/9bEBj7bEOTgeJHhtKQdHT HmB7cyk2Y8pC9/WQixkZfNSo9KbetAFABO+SmqqQJKJw7UjIXRuglnDqVbXx1UWEQfks khrgivbu+c/dBvE6p/inlnwi2lBGNhsVeHVmdyTBHDzSzSPjzu4guibfg85H+uoePumA YRq1X+QLEmeKnWBroeIrm6MrcsMWloGDQSM24dx3xnbQggqdf1AM08/tWfaku0SJjPxT fjUHUHIyVuwZJZk/fATNP8TJG9Ltg7GfASzVsyxYc7CY+9yg9rRC1c5hXl/KGXPZNmCc jgcg== X-Gm-Message-State: ALoCoQkzZW8VXYV5BJXKEgklxRk+pXRf/wJSvaSJfDFxFESLNPfG8ysLlvnf0g/V2IJXTHjGoUfC X-Received: by 10.182.108.136 with SMTP id hk8mr853899obb.11.1383087334287; Tue, 29 Oct 2013 15:55:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.59.82 with SMTP id x18ls233368qeq.88.gmail; Tue, 29 Oct 2013 15:55:34 -0700 (PDT) X-Received: by 10.58.210.39 with SMTP id mr7mr1001103vec.18.1383087334119; Tue, 29 Oct 2013 15:55:34 -0700 (PDT) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id gu4si7262340vdc.124.2013.10.29.15.55.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Oct 2013 15:55:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.52 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.52; Received: by mail-vb0-f52.google.com with SMTP id f13so426803vbg.11 for ; Tue, 29 Oct 2013 15:55:34 -0700 (PDT) X-Received: by 10.58.254.200 with SMTP id ak8mr1011718ved.12.1383087334003; Tue, 29 Oct 2013 15:55:34 -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.220.174.196 with SMTP id u4csp239325vcz; Tue, 29 Oct 2013 15:55:33 -0700 (PDT) X-Received: by 10.60.76.72 with SMTP id i8mr1573019oew.11.1383087333362; Tue, 29 Oct 2013 15:55:33 -0700 (PDT) Received: from mail-oa0-f50.google.com (mail-oa0-f50.google.com [209.85.219.50]) by mx.google.com with ESMTPS id h5si13476457oed.1.2013.10.29.15.55.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Oct 2013 15:55:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.219.50 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=209.85.219.50; Received: by mail-oa0-f50.google.com with SMTP id j6so662130oag.37 for ; Tue, 29 Oct 2013 15:55:33 -0700 (PDT) X-Received: by 10.182.102.2 with SMTP id fk2mr1517845obb.69.1383087333049; Tue, 29 Oct 2013 15:55:33 -0700 (PDT) Received: from localhost.localdomain (sccc-66-78-236-243.smartcity.com. [66.78.236.243]) by mx.google.com with ESMTPSA id s9sm39073887obu.4.2013.10.29.15.55.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 29 Oct 2013 15:55:32 -0700 (PDT) Message-ID: <52703CDF.3070009@linaro.org> Date: Tue, 29 Oct 2013 15:55:27 -0700 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: Patch Tracking Subject: [PATCH] sim/arm: Prevent NULL pointer dereference in sim_create_inferior. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 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: , 2013-10-30 Will Newton PR gdb/9195 * arm/wrapper.c (sim_create_inferior): Avoid calling bfd_get_mach with a NULL bfd. --- sim/arm/wrapper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c index a4b7683..cf10e78 100644 --- a/sim/arm/wrapper.c +++ b/sim/arm/wrapper.c @@ -244,11 +244,15 @@ sim_create_inferior (sd, abfd, argv, env) char **arg; if (abfd != NULL) - ARMul_SetPC (state, bfd_get_start_address (abfd)); + { + ARMul_SetPC (state, bfd_get_start_address (abfd)); + mach = bfd_get_mach (abfd); + } else - ARMul_SetPC (state, 0); /* ??? */ - - mach = bfd_get_mach (abfd); + { + ARMul_SetPC (state, 0); /* ??? */ + mach = 0; + } switch (mach) {