From patchwork Sun Jul 26 14:21:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 30213 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by bilbo.ozlabs.org (Postfix) with ESMTP id 1FFE2B7088 for ; Sun, 26 Jul 2009 00:26:25 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751076AbZGYO0V (ORCPT ); Sat, 25 Jul 2009 10:26:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751379AbZGYO0V (ORCPT ); Sat, 25 Jul 2009 10:26:21 -0400 Received: from mail-bw0-f228.google.com ([209.85.218.228]:60242 "EHLO mail-bw0-f228.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbZGYO0U convert rfc822-to-8bit (ORCPT ); Sat, 25 Jul 2009 10:26:20 -0400 Received: by bwz28 with SMTP id 28so1871568bwz.37 for ; Sat, 25 Jul 2009 07:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:mime-version:content-type:content-transfer-encoding :content-disposition:message-id; bh=wrwPfigMt43Z4oaaDKlrceEmuXFbcmpydU+ZGnmsAZI=; b=OaGGkCVEVhfuRUALV/0weLKiWccjq1DsJ1Iul6tqSq863ZLu985G65lzkF6BHSaB3D SkdTjwW/OP5ANq8jN9cTRQOOWDAyt+oEnVGuwYNu/fXa5XXzJgCZ4GbjX3Beqc3xU+h5 l91cmzxA3R89oROziIXtR+P3u0Lq8cv/IhLHo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; b=T1aZhFPaKchChF2BPbZpDmVOzxh7/+CWujBkq77EMF8EsKPea95j7/vu5e92nltMsk blGIfXuwMUEAwRryMRykb201Hmd9okmiv0Zpdm92LTMr2mYTcbR7isKR4sHG4US6qegu 2+NzSsGPixmBw4HL7dzbeI8awj2h4Z2VWCtFM= Received: by 10.103.217.10 with SMTP id u10mr2284495muq.85.1248531977222; Sat, 25 Jul 2009 07:26:17 -0700 (PDT) Received: from localhost.localdomain (chello089077034197.chello.pl [89.77.34.197]) by mx.google.com with ESMTPS id s10sm18071054mue.8.2009.07.25.07.26.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 25 Jul 2009 07:26:16 -0700 (PDT) From: Bartlomiej Zolnierkiewicz To: jgarzik@pobox.com Subject: [PATCH] libata: add missing NULL pointer check to ata_eh_reset() Date: Sun, 26 Jul 2009 16:21:01 +0200 User-Agent: KMail/1.11.4 (Linux/2.6.31-rc4-next-20090723-04314-g011b7b2-dirty; KDE/4.2.4; i686; ; ) Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, Dan Carpenter , corbet@lwn.net, eteo@redhat.com MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200907261621.01893.bzolnier@gmail.com> Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Bartlomiej Zolnierkiewicz Subject: [PATCH] libata: add missing NULL pointer check to ata_eh_reset() From Dan's list: drivers/ata/libata-eh.c +2403 ata_eh_reset(80) warning: variable derefenced before check 'slave' Please note that this is _not_ a real bug at the moment since ata_eh_context structure is embedded into ata_list structure and the code alwas checks for 'slave' before accessing 'sehc'. Anyway lets add missing check and always have a valid 'sehc' pointer (which makes code easier to understand and prevents introducing some possible bugs in the future). Reported-by: Dan Carpenter Cc: corbet@lwn.net Cc: eteo@redhat.com Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ata/libata-eh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/ata/libata-eh.c =================================================================== --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -2329,7 +2329,7 @@ int ata_eh_reset(struct ata_link *link, struct ata_port *ap = link->ap; struct ata_link *slave = ap->slave_link; struct ata_eh_context *ehc = &link->eh_context; - struct ata_eh_context *sehc = &slave->eh_context; + struct ata_eh_context *sehc = slave ? &slave->eh_context : NULL; unsigned int *classes = ehc->classes; unsigned int lflags = link->flags; int verbose = !(ehc->i.flags & ATA_EHI_QUIET);