From owner-svn-src-head@FreeBSD.ORG Thu Jul 25 16:41:29 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9E2C18C7; Thu, 25 Jul 2013 16:41:29 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-ea0-x22a.google.com (mail-ea0-x22a.google.com [IPv6:2a00:1450:4013:c01::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AD0232341; Thu, 25 Jul 2013 16:41:28 +0000 (UTC) Received: by mail-ea0-f170.google.com with SMTP id h10so1049552eaj.15 for ; Thu, 25 Jul 2013 09:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=fOIy7EnaKbrpvS8VZdKkmZ/KR4UTQSQeJz49iNh9cTM=; b=eObikhMMrCVsl6XicdMdOYDHASK3AjbKk9EmUzcDj+CSf99qTVK41CTh5jSeS4orX+ Ipkn10zuBqM4XGHuryBLyhnHR9xW4aVf8Qhv/OLmVENCglpCmeT8w1QCyqtw/PLzvmkH gPK6r6kzI/qbPBdKvLPxoLPfWUX7TeLcO+7ybPjC5d42vW50DHVP71LIwND/CwxcnJlL b7Xywd/3VFmL62G7dg8Qp269US7TS46Pww1CfLxBw2hhSgrhbq5RH/WKvP6nWHjGBU5M lixmdB5/wi+k+1jTVJqzP3h1o7Wgc23z6HhIoNw5xgO+kXo/O4KaJP++e9VpmTJ/fniN o3dg== X-Received: by 10.14.218.8 with SMTP id j8mr43440948eep.129.1374770486861; Thu, 25 Jul 2013 09:41:26 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (mavhome.mavhome.dp.ua. [213.227.240.37]) by mx.google.com with ESMTPSA id i2sm74841893eeu.4.2013.07.25.09.41.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 09:41:25 -0700 (PDT) Sender: Alexander Motin Message-ID: <51F15532.2060100@FreeBSD.org> Date: Thu, 25 Jul 2013 19:41:22 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130616 Thunderbird/17.0.6 MIME-Version: 1.0 To: John Baldwin Subject: Re: svn commit: r253644 - head/sys/dev/ata/chipsets References: <201307250912.r6P9CkVE054015@svn.freebsd.org> <201307251214.29191.jhb@freebsd.org> In-Reply-To: <201307251214.29191.jhb@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jul 2013 16:41:29 -0000 On 25.07.2013 19:14, John Baldwin wrote: > On Thursday, July 25, 2013 5:12:46 am Alexander Motin wrote: >> Author: mav >> Date: Thu Jul 25 09:12:46 2013 >> New Revision: 253644 >> URL: http://svnweb.freebsd.org/changeset/base/253644 >> >> Log: >> Add missing NULL check after malloc(M_NOWAIT). >> >> Submitted by: Dmitry Luhtionov >> >> Modified: >> head/sys/dev/ata/chipsets/ata-promise.c >> >> Modified: head/sys/dev/ata/chipsets/ata-promise.c >> ============================================================================== >> --- head/sys/dev/ata/chipsets/ata-promise.c Thu Jul 25 08:41:22 2013 (r253643) >> +++ head/sys/dev/ata/chipsets/ata-promise.c Thu Jul 25 09:12:46 2013 (r253644) >> @@ -287,6 +287,10 @@ ata_promise_chipinit(device_t dev) >> /* setup host packet controls */ >> hpkt = malloc(sizeof(struct ata_promise_sx4), >> M_ATAPCI, M_NOWAIT | M_ZERO); >> + if (hpkt == NULL) { >> + device_printf(dev, "Cannot allocate HPKT\n"); >> + goto failnfree; >> + } >> mtx_init(&hpkt->mtx, "ATA promise HPKT lock", NULL, MTX_DEF); >> TAILQ_INIT(&hpkt->queue); >> hpkt->busy = 0; > > Why not use M_WAITOK here? I have no strong opinion. I was going to do it first because only Giant is held at that point. But looking on different device_XXX() internals and other code I've found that they prefer to use M_NOWAIT in alike places. While Giant allows sleeping, it is dropped during sleep, that I guess is not really safe. -- Alexander Motin