Date: Mon, 19 Jan 2009 19:30:03 GMT From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> To: freebsd-scsi@FreeBSD.org Subject: Re: kern/130735: [patch] pass M_NOWAIT to the malloc() call inside cdreaddvdstructure() Message-ID: <200901191930.n0JJU3Sf041556@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/130735; it has been noted by GNATS.
From: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To: Jaakko Heinonen <jh@saunalahti.fi>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/130735: [patch] pass M_NOWAIT to the malloc() call inside
cdreaddvdstructure()
Date: Mon, 19 Jan 2009 22:25:28 +0300
--WIyZ46R2i8wDzkSu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Jakko, good day.
Mon, Jan 19, 2009 at 05:06:47PM +0200, Jaakko Heinonen wrote:
> On 2009-01-19, Eygene Ryabinkin wrote:
> > --- a/sys/cam/scsi/scsi_cd.c
> > +++ b/sys/cam/scsi/scsi_cd.c
> > @@ -4063,7 +4063,7 @@ cdreaddvdstructure(struct cam_periph *periph, struct dvd_struct *dvdstruct)
> > }
> >
> > if (length != 0) {
> > - databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
> > + databuf = malloc(length, M_DEVBUF, M_NOWAIT | M_ZERO);
> > } else
> > databuf = NULL;
>
> This change doesn't look correct. If you use M_NOWAIT malloc(9) can fail
> and return NULL.
Good catch -- I wasn't aware of it. The attached patch should be
slightly better.
--
Eygene
_ ___ _.--. #
\`.|\..----...-'` `-._.-'_.-'` # Remember that it is hard
/ ' ` , __.--' # to read the on-line manual
)/' _/ \ `-_, / # while single-stepping the kernel.
`-'" `"\_ ,_.-;_.-\_ ', fsc/as #
_.-'_./ {_.' ; / # -- FreeBSD Developers handbook
{_.-``-' {_/ #
--WIyZ46R2i8wDzkSu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p
--- sys/cam/scsi/scsi_cd.c.orig 2007-07-21 22:07:45.000000000 +0400
+++ sys/cam/scsi/scsi_cd.c 2009-01-19 22:19:18.000000000 +0300
@@ -4063,7 +4063,11 @@
}
if (length != 0) {
- databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
+ databuf = malloc(length, M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (databuf == NULL) {
+ error = ENOMEM;
+ goto bailout;
+ }
} else
databuf = NULL;
--WIyZ46R2i8wDzkSu--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901191930.n0JJU3Sf041556>
