Date: Thu, 25 Jul 2013 19:41:22 +0300 From: Alexander Motin <mav@FreeBSD.org> To: John Baldwin <jhb@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r253644 - head/sys/dev/ata/chipsets Message-ID: <51F15532.2060100@FreeBSD.org> In-Reply-To: <201307251214.29191.jhb@freebsd.org> References: <201307250912.r6P9CkVE054015@svn.freebsd.org> <201307251214.29191.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <dmitryluhtionov@gmail.com> >> >> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51F15532.2060100>