svn commit: r253644 - head/sys/dev/ata/chipsets
Alexander Motin
mav at FreeBSD.org
Thu Jul 25 16:41:29 UTC 2013
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 at 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
More information about the svn-src-head
mailing list