git: 26fd09ae5fc4 - stable/12 - Make sure that we get the sbuf resources we need.

Warner Losh imp at FreeBSD.org
Sat Jul 31 00:21:18 UTC 2021


The branch stable/12 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=26fd09ae5fc4c1865d7ca15fc33e808c51a8ef52

commit 26fd09ae5fc4c1865d7ca15fc33e808c51a8ef52
Author:     Warner Losh <imp at FreeBSD.org>
AuthorDate: 2020-04-30 00:43:11 +0000
Commit:     Warner Losh <imp at FreeBSD.org>
CommitDate: 2021-07-31 00:02:51 +0000

    Make sure that we get the sbuf resources we need.
    
    Since we're calling sbuf_new with NOWAIT, make sure it can allocate a
    buffer to use. Don't print anything if we can't get it.
    
    Noticed by: rpokala
    
    (cherry picked from commit 4e6a434b6bb81a7ae80911ec6730ff79b9352a88)
---
 sys/dev/nvme/nvme_ctrlr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 18a22aa4f041..a6e2429dbd19 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -59,7 +59,8 @@ nvme_ctrlr_devctl_log(struct nvme_controller *ctrlr, const char *type, const cha
 	va_list ap;
 	int error;
 
-	sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND | SBUF_NOWAIT);
+	if (sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND | SBUF_NOWAIT) == NULL)
+		return;
 	sbuf_printf(&sb, "%s: ", device_get_nameunit(ctrlr->dev));
 	va_start(ap, msg);
 	sbuf_vprintf(&sb, msg, ap);


More information about the dev-commits-src-all mailing list