From 588580a3636f1d2f89071c40a24811393a93accc Mon Sep 17 00:00:00 2001 From: Michael Knudsen Date: Fri, 17 Jun 2011 07:06:48 +0000 Subject: M_WAITOK cleanup of two cases: 1) Allocating with M_WAITOK, checking for NULL, and calling panic() is pointless (malloc() will panic if it can't allocate) so remove the check and the call. 2) Allocating with M_WAITOK, checking for NULL, and then gracefully handling failure to allocate is pointless. Instead also pass M_CANFAIL so malloc() doesn't panic so we can actually handle it gracefully. 1) was done using Coccinelle. Input from oga. ok miod. --- sys/scsi/mpath.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/scsi') diff --git a/sys/scsi/mpath.c b/sys/scsi/mpath.c index f48df0bd1e7..1a938c41c56 100644 --- a/sys/scsi/mpath.c +++ b/sys/scsi/mpath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpath.c,v 1.21 2011/04/27 05:22:24 dlg Exp $ */ +/* $OpenBSD: mpath.c,v 1.22 2011/06/17 07:06:47 mk Exp $ */ /* * Copyright (c) 2009 David Gwynne @@ -395,7 +395,8 @@ mpath_path_attach(struct mpath_path *p) if (target >= MPATH_BUSWIDTH) return (ENXIO); - d = malloc(sizeof(*d), M_DEVBUF, M_WAITOK | M_ZERO); + d = malloc(sizeof(*d), M_DEVBUF, + M_WAITOK | M_CANFAIL | M_ZERO); if (d == NULL) return (ENOMEM); -- cgit v1.2.3